lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Just here expressing my -1

All this code with labeled break looks very ugly and confusing with no
great benefit, very unlike the rest of Lua.

I see the intent of providing a "generic" solution to the continue
issue, but to be honest I can't even remember having used continue at
all for some months now (programming mostly in C, C++ and Ruby).

By all means, thats just my opinion. There seems to be a lot of people
who are excited about this idea, so just ignore me :)

2011/1/27 Axel Kittenberger <axkibe@gmail.com>:
> Rereading my comment, I think one could say, "dont know what this
> should be different to break" --- let me phrase it differently, we
> should habe any keyword or idiom that effectively allows "go back to
> the start of that code block" - for loops this is known in other
> languages as continue.
>
> On Thu, Jan 27, 2011 at 11:34 PM, Axel Kittenberger <axkibe@gmail.com> wrote:
>> First let me thank you for openmindness to this issue!
>>
>> I like the idea of labeled breaks, more power, nothihng really
>> breaking. However, I doubt if it really is a suitable replacement for
>> "continue".
>> When doing idioms around it, we should draft the "worst case" loop,
>> having one break and one continue.
>> So for a start I suppose labels to be after any do, since the existing
>> ':' requires an L-Value, there should no breaks to be used when the
>> parser stack is empty.
>>
>> With this the continue/break idiom would look like this:
>> for k, v in pairs(t) do :loop do:continue
>>   if condition then
>>     break :loop
>>  end
>>   if anotherCondition then
>>     break :continue
>>  end
>> end end
>>
>> I don't know if this really is so good looking.
>>
>> There should be some idiom that effectively allows you to express
>> "this code block is ended herby". For loops this would be equivalent
>> to a continue. Within Do-End block should  execution should resume
>> after the end.
>>
>> Dirks suggeston for:
>> break<label
>> break>label
>> might be one way to achieve this, not yet convinced tough, especially
>> as the syntax should be valid without a label as well for the
>> innermost block.
>>
>> The standard keyword across many languages has become "continue",
>> however It must not be that way, especially for do-end-blocks it would
>> be nice to have a keyword that matches this "get to the end" idea. I
>> don't know a good word, conclude? finish?
>>
>> Kind regards,
>>
>> On Thu, Jan 27, 2011 at 5:42 PM, Roberto Ierusalimschy
>> <roberto@inf.puc-rio.br> 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
>>> 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
>>>
>>>
>>>
>>
>
>



-- 
http://www.twitter.com/lfzawacki
http://www.linesocode.wordpress.com