lua-users home
lua-l archive

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


| It'd be nicer though if this could be a property just like any other in an
| object-oriented way, as it pretty much is at the moment, and not a "magic"
| property as you seem to be proposing. I'm not sure what the answer is;
| there's a tension between the use of tables as objects and as simple
| tables.

I agree with your observation. Tables are multipurpose in Lua and need not be an
array/vector or an associative array, they can be both at once. This is the
reason why I would like "n" renamed or replaced with setn(). I'm not sure what
the better solution is either. I think I'm starting to come down on the side of
setn(). If "n" is renamed there is still potential for a clash. As far as I can
see "n"/lua_getn() is used as an optimisation and should probably be better
hidden.

| I think that if you're likely to want a key called "n", then you shouldn't
| be putting it in a getn-able table (which is generally a list). It's
| sometimes nice to be able to put a list and other elements in the same
| table, but unnecessary.

The functionality is there to mix it and it is often convenient to use. It's
almost encouraged! eg. FnBlah{ 1,2,3 ; n="bill" } . Why should I have to design
round a clumsily named table member variable?

N