PEP308 Late Entry
intentionally at blank.co.uk
Sat Mar 8 11:35:00 CET 2003
I've been putting off making my vote because I wasn't fully happy with
any option. I finally came up with a new choice - it's late, I know,
but here is my late attempt to drum up support.
The syntax would have variants such as...
select : (c1 : r1; c2 : r2; r3)
select s : (v1 : r1; v2 : r2; r3)
select sa, sb : (v1a, v1b : r1; v2a, v2b : r2; r3)
's' stands for 'switch expression'.
'c' for condition.
'r' for result.
'v' for switch-value.
Switch values could even support special syntaxes such as relative
operator prefixes ('<', '>' etc) or perhaps a '..' or 'to' notation
for ranges - though the non-switch first form might be clearer.
1. It handles 'elif' simply and succinctly.
2. It supports the switch/case functionality as a simple extension,
but unlike the earlier proposal does not have to be split over
multiple lines unless clarity genuinely demands it.
3. The use of punctuation keeps it succinct while the initial keyword
makes it clear what is happening (easy to look up in documentation
4. The initial ':' and the use of ':' and ';' in the parentheses
makes it clear that this is not a function, for those who see
function-call notation as implying no shortcircuiting.
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list