On 6/26/06, K.S.Sreeram <[EMAIL PROTECTED]> 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/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com