lua-users home
lua-l archive

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

On Thu, Jul 23, 2020 at 1:43 PM Martin <> wrote:
On 2020-07-23 7:01 p.m., Philippe Verdy wrote:
> As well I consider that the documented syntax of table constructors,
> where explicit keys can be arbitrary expressions whose value is
> unpredictable, such as a function call, is fundamentally flawed if the
> behavior and notably the order of assignments, is not defined at all.
> Thus syntax serves no serious purpose
> I would say the same with the unary operator # which can return
> anything, as well as the corel ibrary function table.maxn()....

It's off-topic but I think array-table dualism can be fixed by adding
syntax for indexing array part. Parenthesis for example. So for "t =
{false, [1] = true}", "t[1]" is true and "t(1)" is false.

This fails because "t" could have a metatable with a __call metamethod. In that case, "t(1)" would be translated roughly to "getmetatable(t).__call(t, 1)".