why no "do : until"?

Robert Amesz rcameszREMOVETHIS at dds.removethistoo.nl
Sun Jan 14 20:58:46 EST 2001


Steve Williams wrote:

>Andrew Henshaw wrote:
>
>> "D-Man" <dsh8290 at rit.edu> wrote in message
>> news:mailman.979261813.31482.python-list at python.org...
>> > On Fri, Jan 12, 2001 at 12:33:58AM +0000, Robert Amesz wrote:
>> > [snip]
>> ...snip
>> [more snip]
>
>>
>> Python's existing 'if condition: break', with its colon, stands
>> out and, more clearly than the 'until', shows its true function;
>> which is, essentially, a goto past 'something else' and out of the
>> loop.  I believe that support for this is more likely than for the
>> other more significant changes.
>>
>
>If you have nested 'do' statements, you have to keep track of the
>nesting structure to find a break target.  Searching for the first
>'break' after a 'do' may or may not find the loop invariant.
>
>Similarly, if you have multiple 'breaks' for a single 'do', the
>first one you find may not be the one that bit you.

The same goes for while and for loops, of course. Anyway, breaks and 
returns are just too useful to do without. (Continues, however, are 
*much* rarer.)


>With 'break', the program flow no longer corresponds to the program
>listing (the original complaint about g*t*, IIRC).

Well, *o*os are a lot more 'insidious' than breaks, continues and 
returns. G***s will let you jump all over the place, whereas the others 
have fixed targets. They're lesser evils, so to speak. 


Robert Amesz




More information about the Python-list mailing list