lua-users home
lua-l archive

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

On Fri, Jun 13, 2014 at 3:54 AM, Dirk Laurie <> wrote:
2014-06-12 1:43 GMT+02:00 Kalafut, Bennett <>:

> In using these I have run into a clear but poorly documented problem
> with table.unpack() .

Not poorly documented.

> For performance reasons, all table accesses (get/set) performed by
> these functions are raw.

This makes sense to me. When I use unpack, it is very often in a spot where an expensive operation would be unwelcome.

However, I don't like these kinds of... "exceptions to the rules". Lua has metatables, I don't like to have to think about whether or not the standard library will respect them, or not. 

In the 5.1 era, when __ipairs wasn't around, the exception had a powerful reason: ipairs won't see your sequence and so neither will unpack. But now, it would be nice to see symmetry and "raw*" versions of the non-metatable variety, if the extra speed is needed... or some other, better method of achieving the same goal.

This is relevant to broader Lua because if I expect my module's table to be unpacked, then I need to export it as a "literal", as opposed to an object where the sequence is calculated.