"Ken Peek" <Peek at LVCM.comNOSPAM> wrote in message news:tdku4kqlqjquf2 at corp.supernews.com... [snip] > Here is my question-- If Python WERE to have a "do...until" construct, what > would be the best way to implement the syntactical rules? It would be best to have one general guarded-loop construct implementing the Knuthian "N and 1/2 times" loop, rather than two different constructs each implementing only a special case of it. Exact syntax sugar could be endlessly (and fruitlessly) debated, but the general idea might be: loop: [suite 1] while [condition]: [suite 2] The 'loop' keyword and associated [suite 1] would be optional, so that just by omitting this clause one would get back to today's while-loop. It is highly debatable whether [suite 2] could be made optional (together with the trailing colon on the while clause) -- it might look nice but I think it would run counter to all of Python's regular syntax (colons are never optional; where a suite is undesired one writes the pass statement). In today's Python syntax, this general loop can be expressed with exactly this Knuthian semantic, BUT the guard clause must be indented the same as the guarded suites in the loop body -- that would be the main difference. (Curiously, [suite 2] in today's syntax DOES turn out to be optional!). Minor differences, strictly sugary ones, are on the spelling of the clauses -- today, 'loop:' is spelled 'while 1:' and 'while condition:' is spelled 'if not condition: break'. Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4