[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: I'd give my right arm for a continue statement
- From: Hans van der Meer <H.vanderMeer@...>
- Date: Thu, 27 Jan 2011 18:05:23 +0100
In my opinion this kind of use could best be characterized with the keyword "goto" not with "break". The keyword "break" in my ears sounds more like "break away" or "break out of". So, why not plainly call it "goto" here? We should not fear the ghost of Edsger Dijkstra coming from his grave to haunt us for it (see his famous article "GOTO considered harmful").
Hans van der Meer
On 27 jan 2011, at 17:42, Roberto Ierusalimschy wrote:
>>> 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
> 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:
> Then, a continue could be written like here:
> while cond do
> do :process_item:
> break :process_item:
> 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