Concrete Proposal: while ... and while ...

Phil Hunt philh at vision25.demon.co.uk
Wed May 19 12:49:39 EDT 1999


In article <7hsv80$g9j$1 at news.tamu.edu>
           cwebster at math.tamu.edu "Corran Webster" writes:
> Last night, after reading the latest assignment in expressions thread, I
> went and hacked together a patch which implements the proposed
> 
> while:
>   ...
> and while test:
>   ...
> 
> form of the while loop.

If this is added to the language, it will make programs harder to read.

With your notation the ``and while ...'' line goes at the same level of
indentation as the original ``while'' line; this makes it look as if it
is ending that block and starting another one.

Perhaps it would be better to have the ``and while ...'' line indented
inside the while loop?

Or better still, just use ``if not test: break''.

> The "while 1" idiom is about the only thing which
> irks me about the language, and it's something I'd like to see changed.
> Compared to how smooth the rest of the language is, it sticks out like a 
> sore thumb.  I'd prefer to see it spelt "do: ... while test: ..." but
> understand the reluctance to add new keywords.

IMO allowing ``while:'', meaning ``while 1:'' is a reasonable shortcut.
 

-- 
Phil Hunt....philh at vision25.demon.co.uk





More information about the Python-list mailing list