[Python-Dev] Simple Switch statement
Phillip J. Eby
pje at telecommunity.com
Sun Jun 25 03:45:14 CEST 2006
More information about the Python-Dev mailing list
Sun Jun 25 03:45:14 CEST 2006
- Previous message: [Python-Dev] Simple Switch statement
- Next message: [Python-Dev] Simple Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 05:30 PM 6/24/2006 -0700, Raymond Hettinger wrote: >[Phillip Eby] > > I would like to be able to use switches on types, enumerations, and the > like. > >Be careful about wanting everything and getting nothing. >My proposal is the simplest thing that gets the job done for key use cases >found >in real code. It's ignoring at least symbolic constants and types -- which are certainly "key use cases found in real code". Besides which, this is Python. We don't select a bunch of built-in types and say "these are the only types that work". Instead, we have protocols (like __hash__ and __eq__) that any object may implement. If you don't want expressions to be implicitly lifted to function definition time, you'd probably be better off arguing to require the use of explicit 'static' for non-literal case expressions. (Your reverse mapping, by the way, is a non-starter -- it makes the code considerably more verbose and less obvious than a switch statement, even if every 'case' has to be decorated with 'static'.)
- Previous message: [Python-Dev] Simple Switch statement
- Next message: [Python-Dev] Simple Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list