PEP-0315--Enhanced While Loop: An idea for an alternative syntax

Peter Maas fpetermaas at netscape.net
Tue Feb 24 11:55:55 EST 2004


Paul Rubin wrote:
> No, you don't understand.  The initialization is part of the loop.
> That is, the replacement for the do loop is
> 
>   while 1:
>     init()
>     if not cond: break
>     body()

You are right, sorry. I was a bit hasty, thanks for the correction.
I reread the PEP and now realize that it is about situations like

         <setup code>
         while <condition>:
             <loop body>
             <setup code>

So the setup code is there to guarantee at least one execution
of the loop body. If this is the case, then the proposed form
"do <setup code> while" is misleading in my opinion. I would
merge <setup code> and <loop body> to <theBody> and solve the
problem with code like

do:
     <theBody>
     breakif <cond>

This would be clearer but I would mind this as well because
I like the minimality of Python and I am completely satisfied
with

while 1:
     <theBody>
     if <cond>: break

Mit freundlichen Gruessen,

Peter Maas

-- 
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail peter.maas at mplusr.de
-------------------------------------------------------------------



More information about the Python-list mailing list