lua-users home
lua-l archive

{ 1 } [1] vs ( { 1 } ) [1]

[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.

AltStyle によって変換されたページ (->オリジナル) /