why no "do : until"?

Delaney, Timothy tdelaney at avaya.com
Wed Jan 10 23:46:41 EST 2001


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.

You fool! You should have known that "loop" was a hated word ;)

Seriously, either of these would work for me. However, I agree that the
biggest drawback is that when you encounter a "while" you don't immediately
know what is going on. Let's look at the other "paired" keywords:

try:
except:

You always know if you see an except: that there is a try: above it
somewhere.

try:
finally:

You always know that if you see a finally: that there is a try: above it
somewhere.

You always know that if you see a try: there is an except: or finally: below
it somewhere. You also know that there *may* be more than one except:, but
that they must immediately follow each other - there can be no outdenting
between them.

With this proposal, if you see a while: you know there *may* be a loop: (or
do: - I prefer loop:) above it, but there *doesn't have to be*. Personally,
I find this a fairly minimal problem though as, with an except, you only
need to go up to the first line with the same or lesser indentation as the
while:.

Tim Delaney
Avaya Australia
+61 2 9352 9079

> -----Original Message-----
> From: Andrew Henshaw
> [mailto:andrew_dot_henshaw_at_earthling_dot_net at python.org]
> Sent: Thursday, 11 January 2001 2:47 PM
> To: python-list at python.org
> Subject: Re: why no "do : until"?
> 
> 
> 
> <gregory_wilson at my-deja.com> wrote in message
> news:93i12s$ul5$1 at nnrp1.deja.com...
> >
> > > Can someone point me at an explanation of the logic for not having
> > > do:
> > > until
> >
> > A proposal I floated a year ago, based on feedback from students in
> > the Python course I teach, was:
> >
> >     do:
> >       first-half
> >     while cond:
> >       second half
> >
> ...snip...
> 
> I almost like this, but it appears to me that it could be a 
> maintenance
> headache.  If you have a significant amount of code done in 
> 'first-half'
> then it would be easy for someone inspecting your code to focus on
> 
> while cond:
>     second half
> 
> as being an entire loop, not realizing that control was 
> returning to the top
> of the loop way up in the code.  This would mean that every 
> time you looked
> at a while loop that was below an indented block, you'd have 
> to check the
> top of that indent for a 'do:' statement.
> 
> I wish I could make a counter-proposal; because, as I said, I 
> almost like
> this idea.
> 
> Andrew Henshaw
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list