PEP-315 ("do" loop)
Dan Bishop
danb_83 at yahoo.com
Tue Feb 17 20:44:38 EST 2004
Wayne Folta <wfolta at netmail.to> wrote in message news:<mailman.78.1077041293.31398.python-list at python.org>...
> > until x <==> while not x
> but at the same time my spider senses were telling me that surely a
> language wouldn't reserve a keyword "until" to simply save someone from
> typing "while not". (Of course, a language like perl might well do this,
Microsoft QBasic did. It allowed all four of the constructs
' pretest loops
DO WHILE condition...LOOP
DO UNTIL condition...LOOP
' posttest loops
DO...LOOP WHILE condition
DO...LOOP UNTIL CONDITION
> At the very least I'd say that you need to choose a word other than
> "while" to avoid this kind of confusion. For example, "do ... until
> ..." loop where "until" <==> "while not" so that you know immediately
> what's going on. Otherwise, when you see a "while", you're never sure
> what kind of loop it is until you look above it and determine it's not
> a "do while".
I agree.
In a similar discussion a while (no pun intended) back, I suggest
adding a keyword like "posttest" to the current while loop syntax.
Unfortunately, it wouldn't easily extend to the "loop and a half"
construct.
More information about the Python-list
mailing list