why no "do : until"?

Steve Williams sandj.williams at gte.net
Mon Jan 15 12:26:22 EST 2001


Andrew Henshaw wrote:

> Steve,
>
> Forgive me for not knowing your stance on some of the earlier points
> discussed, but I was responding to Rober Amesz' do - until proposal.  Would
> not your statements also apply to his use of
>     until condition
> instead of
>     if condition: break
> ?
> I suppose that you could limit each 'do:' loop to one 'until' to avoid the
> multiple breaks problem.  Implicit in that proposal would be the assumption
> that 'if condition: break' would not be allowed in a 'do:' loop.  I don't
> think that suggestion would fly very well.
>
> Given Python's current structure, I still believe that the best compromise
> is the allowance of
>     do:
> as a synonym for
>     while 1:
>
> and leave it at that.
>

[snip]

Andrew

I haven't followed the thread very well.  Your mention of 'g*t*' triggered my
response.  I feel both 'g*t*' and 'break' disrupt the correspondence between
program listing and program flow.

I confess I use 'break' when I have found the result of a serial scan.  "Yes, My
name is Steve W. and I am a 'break' user."  ('Exit do' and 'Exit for' in VB, so
I have much to be ashamed of).

But, I'm not a C programmer and 'while 1' doesn't speak to me in a language I
can appreciate.

I had the hardest time understanding the ISO on/off switch codes of 1/0.  Was
this high-level logic or low-level logic?  Using -1 as a truth value is beyond
my comprehension--since -1 is less than 1, it must be false. . ..

In any case, I want to see a real conditional as part of the 'while'.  That's
just the way I'm put together.  And I don't want the conditional used as some
kind of tatty scope delimiter fifty lines later.  If you need a scope delimiter,
use 'end-while'.

If I have a 'while x <> 0:' statement it tells me something.  It says "this is a
loop and this is how it's terminated".  I can then search for the variable x and
see who sets it or how it's referenced in the loop.  If I have to prime the
value of x before the loop, that's OK with me.  Actually, I like to initialize
all my variables.  I'm kind of a control freak that way.

Conversely, when I see 'While 1', all I know is "this is a loop".  I'm now on
notice to dig deeper and find out how the loop terminates and hope I get it
right.

I don't have an opinion on the 'loop and a half construct'.  I usually take it
as a warning I've not thought out my design thoroughly enough.  Again, just my
prejudice.

When I started learning Python, I wrote some prime number seive finger exercises
using nested 'breaks'.  I quickly learned I couldn't find a break target unless
the entire loop was displayed in one screen fill.  My bifocals just couldn't
keep track of breaks and indents at the same time across screen fills.

These are my prejudices and follies.  I really don't have much to contribute to
the discussion.  Python is a great language as it stands.  The old Python hands
dearly love 'While 1' and more power to 'em, say I.







More information about the Python-list mailing list