Hans Polak wrote: > Hi, > > > > Just an opinion, but many uses of the ‘while true loop’ are instances of > a ‘do loop’. I appreciate the language layout question, so I’ll give you > an alternative: > > > > do: > > <body> > > <setup code> > > while <condition> >
I believe you meant to write PEP 315 in the subject line :) To fully account for loop else clauses, this suggestion would probably need to be modified to look something like this: Basic while loop: <setup code> while <condition>: <loop body> <setup code> else: <loop completion code> Using break to avoid code duplication: while True: <setup code> if not <condition>: <loop completion code> break <loop body> Current version of PEP 315: do: <setup code> while <condition>: <loop body> else: <loop completion code> This suggestion: do: <setup code> while <condition> <loop body> else: <loop completion code> I personally like that style, and if the compiler can dig through a function looking for yield statements to identify generators, it should be able to dig through a do-loop looking for the termination condition. As I recall, the main objection to this style was that it could hide the loop termination condition, but that isn't actually mentioned in the PEP (and in the typical do-while case, the loop condition will still be clearly visible at the end of the loop body). Regards, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com