[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: I'd give my right arm for a continue statement
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 27 Jan 2011 14:42:13 -0200
> > I believe that this "break N" will kill code readability as sure as
> > "goto" would.
>
> Yeah, I would get lost pretty quick! Named labels would help [...]
If that could save Steve's right arm, we like the idea of break with
labels.
In Lua, we cannot have traditional labels, because the syntax "foo:"
already has a different meaning. Instead, a simple syntax would be to
add labels only to "do end" blocks, for instance like this:
do :label:
...
end
Then, a continue could be written like here:
while cond do
do :process_item:
break :process_item:
end
end
There are several details that could change (other mark instead
of colons, whether the label after break needs marks, whether an
optional [or mandatory] label could be added after the corresponding
'end', etc.), but the basic idea would not change much.
-- Roberto
- Follow-Ups:
- Re: I'd give my right arm for a continue statement, Hans van der Meer
- Re: I'd give my right arm for a continue statement, T T
- Re: I'd give my right arm for a continue statement, Dirk Laurie
- Re: I'd give my right arm for a continue statement, Steve Litt
- Re: I'd give my right arm for a continue statement, Philippe Lhoste
- Re: I'd give my right arm for a continue statement, E. Toernig
- Re: I'd give my right arm for a continue statement, Leo Razoumov
- Re: I'd give my right arm for a continue statement, EdK
- Re: I'd give my right arm for a continue statement, Axel Kittenberger
- Re: I'd give my right arm for a continue statement, dcharno
- Re: I'd give my right arm for a continue statement, Renato Maia
- Re: I'd give my right arm for a continue statement, Greg Falcon