[Python-Dev] PEP 3103: A Switch/Case Statement (original) (raw)
Guido van Rossum guido at python.org
Wed Jun 28 16:45:30 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 ]
Looks like this doesn't help at all when pre-computing the dispatch dict based on named constants. So this is a no-go.
I should add that ABC had such named subroutines (but not for switching); I dropped them to simplify things. They're not an intrinsically undesirable or even unnecessary thing IMO. But it doesn't solve my use case for switching. The syntax is also seriously cumbersome compared to a PEP-3103-style switch.
--Guido
On 6/27/06, Talin <talin at acm.org> wrote:
This parallels some of my thinking -- that we ought to somehow make the dict-building aspect of the switch statement explicit (which is better than implicit, as we all have been taught.)
My version of this is to add to Python the notion of a simple old-fashioned subroutine - that is, a function with no arguments and no additional scope, which can be referred to by name. For example: def MyFunc( x ): sub case1: ... sub case2: ... sub case3: ... # A direct call to the subroutine: do case1 # An indirect call y = case2 do y # A dispatch through a dict d = dict( a=case1, b=case2, ccase3 ) do d[ 'a' ]
-- --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 ]