[Python-Dev] Simple Switch statement (original) (raw)
Fredrik Lundh fredrik at pythonware.com
Mon Jun 26 08:07:54 CEST 2006
- Previous message: [Python-Dev] Simple Switch statement
- Next message: [Python-Dev] Simple Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
Here's an argument for allowing names (this argument has been used successfully for using names instead of string literals in many APIs): if there is a spelling error in the string literal, the case will silently be ignored, and who knows when the bug is detected. If there is a spelling error in a NAME, however, the error will be caught as soon as it is evaluated.
which is the rationale for using names in SRE, of course.
and adding a proper switch statement will make this approach a bit robust; if all cases are marked as static (or made static by default), all case expressions will be evaluated up front.
- Previous message: [Python-Dev] Simple Switch statement
- Next message: [Python-Dev] Simple Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]