lua-users home
lua-l archive

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


Using Lua 5.3.

Code:

return { 1 } [1]

Result:

<eof> expected near '['

Code:

return ( { 1 } ) [1]

Result:

1

The question is, why is the first version not accepted? I am not
asking for an explanation why the details are such and such, but
rather for a rationale, if there is one, that a table "literal"
(constructor) should not appear in some expressions unless it is
wrapped in parentheses.

Especially when we consider that there is special syntax for a table
"literal" in a function call that dispenses with parentheses.

Cheers,
V.