lua-users home
lua-l archive

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


> | Date: Sat, 16 Jul 2016 16:07:45 +0200
> | From: Philipp Janda <siffiejoe@gmx.net>
> | 
> | 1.  Rename `table.pack()` (or `table.unpack()`).
> | 2.  Make `table.pack()` return `n` as a separate return value. This
would
> | make it clear that only the table functions that explicitly take end
indices
> | work on packed tables.
> | 3.  Make `table.unpack()` check for an `n` field. But what about the
other
> | table functions? Should `pack()` and `unpack()` move out of the table
> | library?
> | 4.  Set a metatable with `__len` on packed tables. Again, what about the
> | other table functions (mostly `insert()` and `remove()`)?
> | 
> | Philipp
> | 

And/or rename the 'table' library the 'list' library to reflect what is
actually in it?

The real generic 'table' stuff is actually in the 'Basic Functions' library
('next', 'pairs', 'rawget, 'rawset', 'setmetatable', 'getmetatable').
Everything currently in the 'table' library actually assumes 'list'
structure and this name change would make that clear and open the way for
using it as a metatable in the same way as the 'string' library is (though
not by default, since it is not appropriate for all tables). While we are
about it, 'ipairs', if not deprecated altogether (my views on this have been
expressed before) should be moved to this 'list' library.

Plus if you do this, it would be possible to create a new 'table' library
moving the generic table functions out of the 'Basic Functions' library.
Again this would then be available for use as a metatable.

John.