while (a=b()) ...

William Tanksley wtanksle at dolphin.openprojects.net
Wed May 12 17:44:48 EDT 1999


On Wed, 12 May 1999 13:51:38 GMT, Tony J Ibbs (Tibs) wrote:
>Paul Boddie <paulb at infercor.no> wrote:
>> Of course, the "while 1" is a bit "ugly", but then it merely causes the
>> reader to go looking for the exit points. We could change that to a
>> single keyword acting as a synonym if it really bothered a significant
>> number of people, but I don't see too much of a need for that.

>...not that he started the discussion this time round, or necessarily 
>espouses any of the views I'm reacting to...

>I wonder what actually *starts* people on this worry - are they finding 
>the extra "1" in "while 1:" to be worrisome (and only then getting all 
>purist about whether "break" is really some sort of "goto" - oh dear),
>or would they be equally worried if it were instead just a simple
>"while:" with no expression in there at all?

Gee, and I wasn't going to get involved this time...

No, what "starts people on this worry" is that "while 1" doesn't say what
it means.  It's not inefficient or too verbose, it's just not direct.
Most everywhere else in Python, if I read a line literally I know what
it's doing.  That line you just have to mentally translate.

Now, I have to say that I _do_ like "while 1" better than most of the
alternatives people have proposed for it -- ranging from the deadly and
much-feared "=" expression to the merely homely ":=" expression.  Why, I'm
so open-minded on this topic, I even have come to hate my *own*
suggestion, the "from" statement (which looks like Yee's from statement
but can be used anywhere).

I think the best solution is the 'for' statement.  Right now, that means
each person has to write a kinda ugly wrapper, but that seems to be a
small cost.  Perhaps in Python 2.0 the wrappers won't be needed.

>Hmm. Personally, I'm still much more worried about 0 introducing octal
>numbers than by having to type an extra "1" to get infinite loops, 
>which shows how much importance I place on *that*, I hope.

My problem is when I *forget* to worry about octals.  I do NOT like that
convention either :-).  A pity it's too late to adopt Ada's convention --
base#number.  8#777 == 10#255 == 16#ff == 2#11111111.

Where did you get the idea that you have to type an "extra" 1, anyhow?
Also, where did you read that someone wanted an infinite loop?

>Tony J Ibbs (Tibs)      http://www.tibsnjoan.demon.co.uk/

-- 
-William "Billy" Tanksley
"But you shall not escape my iambics."
           -- Gaius Valerius Catullus




More information about the Python-list mailing list