lua-users home
lua-l archive

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


[You don't want to propose a change to the language, do you? :-)]

Given the easiness to workaround it, there are certainly more worthwhile things to concentrate efforts on ;-)

I was just wondering, despite having some dejavu that years ago that already surprised me about Lua. The thing why it catches my attention was because of my experiences with PHP. When I learned that mycall( )[ 0 ] did not work its way through the parser, I thought, what kind of nonsense language is that? ;-)




On Wed, May 14, 2014 at 6:51 PM, Matthias Kluwe <mkluwe@gmail.com> wrote:
Am 14.05.2014 17:33, schrieb Rena:
> On 2014-05-14 4:47 AM, "Axel Kittenberger" <axkibe@gmail.com
> <mailto:axkibe@gmail.com>> wrote:
>>
>> local season = 's'
>> ...
>> local text =
>>    ({
>>        s = 'summer term',
>>        w = 'winter term'
>>    })[ season ]
>>
>> Why do I need brackets around the curly brackets?
>>
>> Why is
>>
>> local text =
>>    {
>>        s = 'summer term',
>>        w = 'winter term'
>>    }[ season ]
>>
>> not valid?
>>
>> Its no deal breaker, so I do brackets. But I just wonder...
>>
>> Kind regards, Axel
>
> I don't know the exact reasoning, but I'll note that these also won't work:
>
> {f=print}:f()
>
> "hi":upper ()
>
> Both cases also require parens.

As required by the syntax.

I guess this has been done to simplify the grammar, or ease the parsing.
Perhaps there is some unwanted ambiguity when this was allowed. When you
have a plausible reason, this might be added to one of the FAQs...

[You don't want to propose a change to the language, do you? :-)]

Regards,
Matthias