Add 'when' variant.

This commit is contained in:
Guido van Rossum 2003-02-08 02:12:43 +00:00
parent edf0585da8
commit 717ec38a5c
1 changed files with 12 additions and 0 deletions

View File

@ -153,6 +153,18 @@ Variations
to several people. They all thought that if C was false, it would
leave x unchanged. So don't even think about this one!
---
Another variant proposes to use 'when' instead of 'if':
<expression1> when <condition> else <expression2>
I don't see the advantage of 'when' over 'if'; it adds a new
keyword which is a major extra hurdle to introduce this. I think
that using a different keyword suggests that the semantics are
different than those of an 'if' statement; but they really aren't
(only the syntax is different).
Copyright