[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Request for 5.4: adding [] as table creation syntax for Lua 6.0
- From: Coda Highland <chighland@...>
- Date: Wed, 13 Jul 2016 22:57:01 -0700
On Wed, Jul 13, 2016 at 10:52 PM, Coda Highland <chighland@gmail.com> wrote:
> On Wed, Jul 13, 2016 at 10:35 PM, Thomas Jericke <tjericke@indel.ch> wrote:
>> The only good solution I see is to not allow function calls by array
>> constructors. So you would always have to write:
>> t([])
>> t([1])
>> t([1,2])
>> ...
>>
>> Disallowing only the single element case would be very error prone IMO.
>
> I, for one, don't have a problem with this. It certainly won't look
> strange; people are used to that kind of syntax.
>
> Another option might be {[ ]}. It's not FANTASTIC, but it's still (1)
> obviously a table constructor (though a specialized type) and (2) a
> syntax error in current Lua so it won't break any existing code.
>
> /s/ Adam
... Bleh, I say that, and then I realize how much of an issue it could
be in terms of actually parsing the grammar, due to the ambiguity of
{[ 1 ]} and { [1] = 2 }. I haven't hacked on Lua's parser itself to
know how much of an issue it would be to handle that production (it
requires an unbounded amount of lookahead to do it with an LL or LR
parser but it might not be a problem with Lua's parser implementation
-- it wouldn't be a problem with the parser architecture I built
myself for a class).
/s/ Adam