lua-users home
lua-l archive

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

On Sat, Jun 14, 2014 at 6:13 PM, Thiago L. <> wrote:
mtmt = {__index = {__index = {test = "test"}}}
mt = setmetatable({},mtmt)
t = setmetatable({},mt)

No, because that's a limitation designed to guide the developer towards a particular design. Also, the workaround is trivial.

In the case of unpack, it goes toward interaction between consumer (application) and producer (module). If I give you a table that I want you to use and you might unpack it, then I need to make a literal. I can't give you the object, if the object derives a sequence from a hidden table or some formula.

This is very much the case with what I'm working on. I have a keyframe engine that stores media segment time values in a sequence. Something like  `[1] = 1, [2] = 100`, etc.

Now, I don't want the time values to "unpack" (I don't want t[50] to return the 50th frame). However, these values are in a hidden table, so unpack would return nothing. If it used __index, it would work as an object.

The "mare's nest" might be more about any question about whether __ipairs would be used or __index.

Given that, I guess I don't care about this as much. I can see that it's not a slam dunk.