I'm coming from Tcl-world ...

Michael Hudson mwh at python.net
Sat Aug 3 17:28:46 CEST 2002


Tim Daneliuk <tundra at tundraware.com> writes:

> Martin v. Löwis wrote:
> 
> > [PEP 275]
> 
> This seems to me to just be syntactic sugar and thus unneeded.
> Switch/Case like constructs are trivially, and more richly,
> implemented using dictionaries to associate a switch value with a
> particular behavior or result.

Not really.  Something like:

int a, b, c

switch (v) {
    case 1:
        a = 0
        break;
    case 1:
        return b;
    case 1:
        c += 1
        break;
}

would be tedious to do using dictionaries (i.e. where the different
cases need access to different bits of the local environment).

Cheers,
M.

-- 
  On the other hand, the following areas are subject to boycott
  in reaction to the rampant impurity of design or execution, as
  determined after a period of study, in no particular order:
    ...                              http://www.naggum.no/profile.html



More information about the Python-list mailing list