lua-users home
lua-l archive

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

Suppose I have tables referring to tables (by their field values), or functions referring to upvalues (by closure).

Given a table, I can know what it refers to by iterating over its contents. And given a closure, I can use the debug facilities to find its upvalues. I can do both recursively to obtain all objects or upvalues referenced.

Is it possible to go in the other direction? To find all references to a given value (say a table) in other tables or closures (as upvalues)?

Wouldn't the garbage collector have this information? It's not exposed in any debug facilities, is it?

I'm just pondering about the idea of one object being able to notify other objects that reference it, without having to keep a list of listeners that explicitly subscribed for notifications.