[Python-3000] Switch/Case statement PEP (original) (raw)

Josiah Carlson jcarlson at uci.edu
Tue Dec 12 04:23:06 CET 2006


"Marcin 'Qrczak' Kowalczyk" <qrczak at knm.org.pl> wrote:

Josiah Carlson <jcarlson at uci.edu> writes: > After reading Thomas' post and Talin's response, I'm going to have to > agree with Talin; syntax options are moot until we can decide what is > acceptable in the case EXPR. IMHO any expression should be acceptable, it should be evaluated when being compared, and there should be other means (independent from switch/case) to make named constants which may be expanded at compile time.

The problem with allowing any expression is that then switch/case statements are, strictly speaking, a new syntax for a simplified if/elif/else chain; offering precisely no advantages over what currently exists. One important point of the entire Switch/Case statement discussion was that if we couldn't make it fast with dictionary dispatch, then it doesn't really have a use. Deciding on what can be made into compile time constants, will allow for dictionary dispatch, and gives the PEP a point.



More information about the Python-3000 mailing list