lua-users home
lua-l archive

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


On 15.03.2018 12:40, Viacheslav Usov wrote:

Secondly, there is another problem, which is probably much bigger than the above. There is a lot of Lua code that thinks table.foo = nil removes foo from the table. That code, when run in a system where that leaves foo in the table, albeit with a nil value, can run into serious performance problems, silently again.

The expectation that table.foo = nil removes foo does not only runs silent performance problems. In the case of sequences it runs into a direct incompatibility in behavior.

table = { 1, 2, 3}
table[#table] = nil
table[#table + 1] = 42

How does table look like now?
{ 1, 2, nil, 42} or {1, 2, 42} depending on the undef feature used or not.

Well this looks like a major incompatibility to me, and personally I would prefer a compile error over a semantical change within the same syntax.

That said, I also think that table[#table] = nil should still remove the last element of a sequence for backwards compatibility only. And the new feature (sequences with holes) should get a new syntax.
--
Thomas