[Python-Dev] PEP 3103: A Switch/Case Statement (original) (raw)
Guido van Rossum guido at python.org
Tue Jun 27 17:11:39 CEST 2006
- Previous message: [Python-Dev] PEP 3103: A Switch/Case Statement
- Next message: [Python-Dev] PEP 3103: A Switch/Case Statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 6/26/06, K.S.Sreeram <sreeram at tachyontech.net> wrote:
Guido van Rossum wrote: > I think we need a PEP for const/static/only/cached/precomputed or > whatever people like to call it.
fredrik's got a micro pep at http://online.effbot.org > Once we have (say) static, I think making the case expressions static > by default would still cover all useful cases, and would allow us to > diagnose duplicate cases reliably (which the if/elif chain semantics > don't allow IIUC). Making case expressions default static would be very surprising to users because of the restrictions placed by static. For instance 'case in a', will not support containers which have a custom contains method. It will also not support containers like lists, and sets because they are mutable. IMHO this doesn't feel very pythonic. Instead if we redefine the goal of the switch statement to be 'ease of expression' rather than 'optimization', then it can just be used as a concise alternative to if-elif chains, and we can make 'case in a' work with all containers where a regular 'in' statement works AND still give the possibility of fast lookup when the programmer wants, using explicit static. I feel programmer expressivity is more important, and default static case expressions looks like premature optimization.
You've just placed yourself in School Ia (see the updated PEP). I respectfully disagree.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] PEP 3103: A Switch/Case Statement
- Next message: [Python-Dev] PEP 3103: A Switch/Case Statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]