lua-users home
lua-l archive

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


John,

I like the "oldindex" metamethod, only I'd call it delete or something. In fact, I like the idea so much that I'll be trying it out with the mutated Lua dialect I'm working on.

Generally, I think the Lua table concept as a whole could benefit from a reboot, but it's probably not feasible since it would break all the Lua apps out there.

It's a matter of taste, of course, but there are two directions the table could go that would make me really happy:

Option a) Keep the distinction between the hash part and the array part, but don't allow users to manipulate the array index at all - effectively transforming the array part into a sequence where the index is only incidental. By doing this, we could get rid of all the nastiness that comes from using the array index for counting.

Option b) Fuse the array and hash part into one thing. This is a point that PHP actually gets right. The index becomes "just a value" with no meaning except for lookup, be it numerical or string-y. As a result, tables would become ordered hash maps. This, too, would be a major breaking change, but it's probably what most (new) users expect behavior-wise.

As I said, I've got something of a horrible Lua mutation lab experiment going on, maybe I'll just try a re-implementation of the table object to see how it feels (...or die trying).

I wouldn't advocate something like that for mainline Lua, though.