do...until wisdom found...
Alex Martelli
aleaxit at yahoo.com
Tue Apr 17 15:16:47 EDT 2001
"Dennis Baker" <drbaker at softhome.net> wrote in message
news:mailman.987527904.6377.python-list at python.org...
> On Tue, 17 Apr 2001 09:28:15 -0700 Bob Cannard <bob_cannard at mentor.com>
wrote:
>
> ) Has no one else found that the majority of while-type
> ) loops actually need some code before the test and some
> ) after?
Yes. Donald Knuth, one of the truly greats of programming,
pointed this out in the mid-'70s in an article in Computing
Surveys (ACM) with a provocative title -- "Structured programming
with GOTO statements". His "N and 1/2 times loop" classic
construct is exacly the one you, Bob, identified.
> ) Doubly so in Python where it seems impossible
> ) to embed a local side effect in the while condition.
> ) As a result, most non-for loops degenerate into
> )
> ) while 1:
> ) set up for this cycle
> ) if c: break
> ) whatever needs to be done
Knuthian syntax might be more like:
loop:
set up for this cycle
while not c:
whatever needs to be done
and I do think it would be superior sugar. The semantics
are identical to the above snippet, anyway.
> That's a product of poor design. I consider it a failure to resort to
this sort
Uh, Dennis, have you READ Knuth's classic article? Finding
reprints of the mid-70's original issue of "Computing Surveys"
may be hard, but it IS one of the articles that define the
history of programming, so it's been widely reprinted, for
ex in his "Literate Programming" book, an interesting one
to read anyway. Please come back with your critique AFTER
you are aware of the Master's arguments...
Alex
More information about the Python-list
mailing list