[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Predefined labels (Inspired by discussion on: Why do we have ipairs?)
- From: Paige DePol <lual@...>
- Date: Wed, 2 Jul 2014 17:18:40 -0500
On Jul 2, 2014, at 4:46 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
> Am 02.07.2014 23:14 schröbte Paige DePol:
>> On Jul 2, 2014, at 8:56 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>
>>> 2014-07-02 13:51 GMT+02:00 David Demelier <demelier.david@gmail.com>:
>>>
>>>> I don't know any other language that use goto continue or goto break to
>>>> control the loop, it's just a bloody idea.
>>>
>>> Lua 5.2 uses "goto continue" if you want to, and implicitly translates
>>> "break" to "goto break" whether you want to or not. The opportunity
>>> to provide a "continue" keyword in Lua 5.3 seems not to have been
>>> taken.
>>>
>>> So basically my post says: if you can't beat them, join them.
>>> If you are forced to type "goto continue", at least be spared
>>> the trouble of inserting ::continue::. It *is* just an idea.
>>
>> If you are going to hack your copy of Lua to implicitly add a `continue` label then why wouldn't you just add the `continue` keyword and save the ugliness that is `goto continue`?
>
> Apparently there already is a hidden `break` label, and substituting the `break` statement with `goto break` would replace an ad-hoc convenience feature with a more basic mechanism (which seems very Lua-like, IMHO), freeing a keyword in the process. As a bonus one could easily add other predefined labels like the often requested `continue`, `redo` (as in perl), and possibly others, without any new keywords. We probably should talk about reserved label names though ...
What is the fascination with removing keywords? Reminds me of newspeak from 1984... doubleplusungood! It is not like the keyword is using up system resources or anything!
If you are going to have implicit labels then why not have the keyword that goes with it? A matched set, as it were... also, adding implicit labels to Lua means your source code will only work on your hacked Lua. Other versions of Lua will have no idea what to do with `goto continue` if that Lua isn't making the implicit labels your source expects.
Also code wise, if I see "goto {something}" I am going to be looking for a {something} label, however, if I see `break` or `continue` I know what to expect, and I know the language has already facilitated placing labels for those keywords in the correct places. To me, `goto break` or `goto continue` just looks like someone was confused when writing the code! ;)
>>> But the fact that no other language uses it, if true, makes me like
>>> it better, not less.
>>
>> Uh... okay. That is kind of weird, you know! ;)
>
> It wouldn't be the only unique feature of Lua, and so far most of those turned out ok.
No, but liking something just because something else doesn't have it is just strange, to me.
Sort of reverse-hipster or something, LoL! ;)
~pmd