On Monday 13 June 2005 08:07, Nick Coghlan wrote:
> Raymond Hettinger wrote:
> > [BJ�rn Lindqvist]
> >
> >>I would like to have do-while's like this:
> >>
> >>do:
> >> <body>
> >> until <cond>
> >>
> >>But I'm sure that has problems too.
> >
> > That looks nice to me.
>
> And this could easily be extended to allow code both before and after
> the 'until', giving a fully general loop:
>
> do:
> <body-1-or-more-times>
> until <cond>
> <body-0-or-more-times>
> else:
> <on-natural-loop-exit>
>
> In fact, this would simply be giving "looks like executable
> pseudocode" syntactic sugar for the current 'do-until' workarounds:
>
> while 1:
> <body-1-or-more-times>
> if <cond>:
> <on-natural-loop-exit>
> break
> <body-0-or-more-times>
Yet another way to spell this would be make the default for the while
statement be true so the 1 could be omitted and then add a condition to
break.
while:
<body-1-or-more-times>
break <cond>:
<on-natural-loop-exit>
<body-0-or-more-times>
I think this would be feature creep. It complicates the language for a very
small gain. While the added syntax would be intuitive, it only saves a line
or two over the existing syntax.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com