[Python-ideas] Another idea for a switch statement
haoyi.sg at gmail.com
Wed Oct 12 06:09:38 CEST 2011
Generally, I don't think much of switch statements as they appear in
C/C++/Java. Those sorts of things can only switch on trivial data
(i.e. ints, chars, strings in C#) and go against the OO grain of the
language: They encourage people to store special "behavioral flags"
inside objects to modify their behavior with switches, rather than
using proper OO inheritance/subclassing.
Furthermore, they don't really provide much of a syntactic advantage
over chained elifs, or using a delegate dict (which has the advantage
of being programmatically modifiable. Both of those are far more
flexible and powerful.
Unless we're going all the way to F#/Haskell/Scala style 'match'
statements (which are completely awesome), there really isn't much
point in them.
On Tue, Oct 11, 2011 at 6:15 PM, Chris Rebert <pyideas at rebertia.com> wrote:
> On Tue, Oct 11, 2011 at 7:33 AM, Lucas Malor <rwwfjchuws at snkmail.com> wrote:
>> Hello all. I read PEP 275 but I don't like the syntax of examples.
> I doubt PEP 275 or PEP 3103 were rejected based just on syntax grounds.
> Python-ideas mailing list
> Python-ideas at python.org
More information about the Python-ideas