[Python-Dev] while:

Gareth McCaughan gmccaughan at synaptics-uk.com
Thu Jul 21 16:17:22 CEST 2005


On Thursday 2005-07-21 01:22, Martin Blais wrote:

> The Rule of Least Surprise says to me that "while:" would do the least
> unexpected thing.  There are only two possibilities: the test is
> implicitly false, in which case "while:" would make no sense (i.e. the
> block would be ignored).  Therefore the other only sensible case is
> that the test is implicitly true, which can be useful (and also
> happens to be a very common idiom).

To me, the "least unexpected thing" for "while:" to do is to
raise a syntax error. The principle of least surprise doesn't
mean that for every sequence of tokens you should pick the
least surprising thing it could do, and give it that definition.
(That's what they do in C++, except for the bit about picking
the least surprising semantics.)

-- 
g



More information about the Python-Dev mailing list