REPEAT... UNTIL ?

Beej Jørgensen beej at piratehaven.org
Wed Jul 3 18:51:31 EDT 2002


In article <mailman.1025724185.22228.python-list at python.org>,
Gustavo Cordova  <gcordova at hebmex.com> wrote:
>would be exactly the same as:
>
>"""
>while 1:
>  ...
>  ...
>  ...
>  if bexpr: break
>"""
>
>no?

Sigh.  It's the age-old issue.  More looping primitives, or fewer?  I
always wanted more, but people would argue against me that the same
thing can be done with a normal while loop.  Well, of course it can.  In
fact, all the loops can be reduced to one statement, a la:

loop:
  if cond: break

But not even the purists will go that far.  But as the language ages, it
becomes more and more set in stone.  Backward compatibility will
certainly be trashed if a do-while loop is introduced, so it's not an
issue to take lightly.

(The other side of the coin is that my only argument for more looping
primitives is that while-1 loops are ugly-looking, and don't make for
the most readable code.  Some people disagree or feel it's less
important.  And personally I always feel like I'm undergoing some kind
of algorithmic failure when I code one; like I must not be doing the
Right Thing.  But in Python, it is.)

It's not really even worth arguing about at this point unless you can
come up with the killer app for do-while loops.  The battle lines are
clear, and either someday it'll be added, or it won't.

-Beej




More information about the Python-list mailing list