lua-users home
lua-l archive

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

сб, 17 авг. 2019 г. в 06:30, Philippe Verdy <>:
>   t= { y = sin x };
>   t= { y = sin, x }
here is no ambiguities
> Lot of ambiguities will happen, even when you don't specify the keys:
>   t = { sin 0 };
Here is no ambiguities
>   t = { sin, 0 };
> or:
>   t = { 12 - 1 };
This will be t= { 11 }
>   t = { 12, - 1 };

> The way by which semicolons were made optional between statements in Lua is already broken, but more limited; the colon separators in table data initializers would be much worse (in fact there are all the same ambiguities if you drop the semicolons between function parameters, or between return values, or between multiple right-hand side values of an assignment, it would make the language extremely ambiguous with lots of caveats in the parser, or forcing it to use backtrailing and maintaining a complex structure to memoize the backtrailing state)

All ambiguities could fixed with explicit comma
Main aim is functions groups
  f1=function() end
  f100500=function() end
They could be easily moved into table and back
  f1=function() end
  f100500=function() end
without any additional editing.
Now it could be done with construction like this

t={} do local _ENV=setmetatable(t,{__index=_ENV})
    function f1() end
    function f100500() end