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

Magnus L. Hetland mlh at idt.ntnu.no
Wed May 19 17:50:06 EDT 1999


cwebster at math.tamu.edu (Corran Webster) writes:

> In article <y0j675pmg6c.fsf at vier.idi.ntnu.no>,
> Magnus L. Hetland <mlh at idt.ntnu.no> wrote:
> >cwebster at math.tamu.edu (Corran Webster) writes:
> >
[...]
> 
> It might be the Guido-approved version - I can't recall the exact form
> of the approved form.  If this is in fact it, then I think my proposal
> has a slight advantage over this in simplicity.  This form allows two
> tests (presuming something other than '1' is permitted after the first
> while), where my proposal has precisely one test for the loop, which
> seems more natural to me.

Maybe -- but then the keyword "while" seems a bit strange...

while:
    line = readline()
and while line:
    print line

To me, the "while: line=readline()" sounds like some kind of
condition, and it certainly isn't... I would find this more
understandable:

repeat:
    line = readline()
and while line:
    print line

But then we have another keyword again...

> 
> No, "while:" is not permitted without the "and while" later.  The precise
> grammar is
> 
> while [':' suite 'and' 'while'] test ':' suite ['else' ':' suite]
> 

OK - I see.

[snip]

> It seems to me that with this change, 'while 1:' will be used much
> less often, and it's not worth the additional complexity to make
> the '1' optional.

I agree... I think I meant it should be obligatory, since I find
"while:" even more meaningless <wink>. Oh, well...

> 
> Corran
> 

--

  Magnus
  Lie
  Hetland        http://arcadia.laiv.org <arcadia at laiv.org>




More information about the Python-list mailing list