lua-users home
lua-l archive

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


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