[Python-Dev] Wishlist: dowhile

Guido van Rossum gvanrossum at gmail.com
Tue Jun 14 20:46:39 CEST 2005


On 6/14/05, BJörn Lindqvist <bjourne at gmail.com> wrote:
> Oh. I had the impression that the reason do-while's (or do-until's
> which I like more) wasn't implemented in the language was because it
> was impossible to find an acceptable looking syntax.

No, just because it's fairly redundant.

>  > > Yes, but grepping the stdlib produces over 300 hits for "while 1:" and
> > > "while True:" combined. Some of those a "if <cond>: break" in the
> > > middle and some would be better written as generators, but lots of
> > > them would be rewritten as do-while's. So I think there is more than
> > > enough use cases for syntactic sugar for do-while loops.
> >
> > The PEP 315 solution looks much better than an "until" that isn't what
> > it looks like.
> 
> What do you mean by that? The proposed until would work exactly like
> it do in languages that support until loops. I'm also reasonably happy
> with PEP 315, except that it seems to force you to end it with a pass
> if the condition is last in the loop. But is discussing do-while's
> beating a dead horse or is there a possibility that do-while's will
> someday make it into the language?

You are proposing 'until' that is indented. That is unlike any other
language. Translating this to curly-braces style, you're proposing
this:

  do {
    ...body...
    until (x <= 0);
  }

I find this bizarre, not " exactly like it do [sic] in languages that
support until loops."

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list