lua-users home
lua-l archive

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


If by weak, you mean weak *keys* in the prototype, then I don't think it can be. Otherwise, if at some point a key is unused (not explicitly assigned a value to that key in at least one of the tables using the prototype), then that key is going to get collected by the GC. This would make your prototype table gradually depopulate over time, depending on how it was used. I think the same also applies to the values.

And I don't see how appearing in multiple metatables makes a difference. I don't see how weak tables could work here.

--Tim


On Jun 29, 2013, at 1:43 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:

i.e. __newindex exploits the mechanism created for __index, if any.

Now comes my question. That prototype table: should it be weak? Does
the answer depend on whether the prototype may appear in more than one
metatable?