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 <[EMAIL PROTECTED]> 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 case_1:
>        ...
>
>     sub case_2:
>        ...
>
>     sub case_3:
>        ...
>
>     # A direct call to the subroutine:
>     do case_1
>
>     # An indirect call
>     y = case_2
>     do y
>
>     # A dispatch through a dict
>     d = dict( a=case_1, b=case_2, c_case_3 )
>     do d[ 'a' ]

-- 
--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

Reply via email to