{ 1 } [1] vs ( { 1 } ) [1]
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: { 1 } [1] vs ( { 1 } ) [1]
- From: Viacheslav Usov <via.usov@...>
- Date: 2021年1月14日 18:30:23 +0100
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.