[Python-ideas] Match statement brainstorm
Stephen J. Turnbull
stephen at xemacs.org
Wed May 25 01:03:04 EDT 2016
Paul Moore writes:
> With a switch statement, however, the subject is stated once, at the
> top of the statement. The checks are then listed one after the other,
> and they are all by definition checks against the subject expression.
> And in fact, for me that's the distinguishing feature of a switch
That may also make some optimizations easier to spot.
I'm also -1 on the ?= syntax, which reads "maybe assign" to me, but
that covers way too much ground (and in particular has been proposed
for "null-propagation" in the recent past).
I admit I'm not in love with the "switch/case" syntax for the kind of
matching intended here, as C's switch is way too burned into my
thinking. I think it's gone right through the EEPROM silicon into the
plastic case[sic, just can't get away from those preexisting "case"es!]
Look Ma! No new keywords! Yeah, I know, "for" and "try" both have
very strong connotations in Python already, so this may be a "not even
the Dutch could like it" automatic-parser-only syntax.
More information about the Python-ideas