[Python-ideas] Yet Another Switch-Case Syntax Proposal
Steven D'Aprano
steve at pearwood.info
Sat Apr 26 17:17:23 CEST 2014
On Sat, Apr 26, 2014 at 03:03:32PM +0200, Philipp A. wrote:
> what y’all are missing about switch/case is that it’s *not* necessarily a
> series of comparisons in most languages.
*Some* people might be missing that, but not *all* of us :-)
Before commenting further, anyone who isn't familiar with the two
rejected PEPs on this topic should read them:
http://legacy.python.org/dev/peps/pep-0275/
http://legacy.python.org/dev/peps/pep-3103/
Also, folks might like to review the wide range of semantics and syntax
for switch/case in different languages:
http://rosettacode.org/wiki/Conditional_Structures
By my count, there are:
50 languages with no case/switch at all
30 languages using the keyword "case"
19 using "switch"
15 using "select"
3 using "when"
2 using "match"
2 using "given" (treating Perl 5 and 6 as distinct languages)
1 using "evaluate"
1 using "caseof"
1 using "if" (with a switch-like syntax)
The above counts should be mostly accurate, but I don't guarantee that
they are exactly correct. Apart from the possibility of counting errors,
there were a few cases where I had to make a judgement call on whether
or not language feature X was analogous to a switch or not.
--
Steven
More information about the Python-ideas
mailing list