why no "do : until"?

Robert Amesz rcameszREMOVETHIS at dds.removethistoo.nl
Thu Jan 11 19:33:58 EST 2001


Delaney, Timothy wrote:

>Alex Martelli, notice where you went wrong ...
>
>You proposed
>
>     loop:
>          something
>     while condition:
>          something else
>
>and got shot down in flames. However,
>
>     do:
>          something
>     while condition:
>          something else
>
>seems to be garnering support.

Well, to put in my fl 0,02 (soon te be about E 0,01 <g>) I have to say 
I feel that syntax is flawed: not only does it break the block in two 
parts (whereas a dedent in other cases means the end of the block is 
reached), but it's also visually ambiguous because a 'while' could be 
the start of a loop, but it might also be somewhere in the middle of 
one.

As I prefer programming languages to be as context-free as possible, 
I'd like to make a counter-proposal:

     do:
          something
          until condition
          something else

The 'something else' is optional, of course. As for semantics,

     do:

would mean *exactly* the same as

     while 1:

and

     until condition

would mean *exactly* the same as

     if condition: break


All syntactic sugar, I admit, but so was the other proposal. However, 
this proposal would have a lot less impact on the overall syntax of 
Python, which would seem to be more in keeping with its modest goals.


Robert Amesz



More information about the Python-list mailing list