lua-users home
lua-l archive

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


Peter Hill:
> The variable 'b' is no longer accessible so its contents should, ideally,
> be garbage collected. Is it? Or is the local frame containing 'a' & 'b'
> held onto because 'a' is still referenced?

Ben Sunshine-Hill:
> From what I've seen, upvalues are references to objects, not to scopes. So
> since the only upvalue to z() is a, there's nothing preventing b from
> being gc'ed.

Thanks for the reply.

The question, though, is which *object* the lexically scoped variable 'a'
(not its content object) is living in. If it lives in some sort of 'local
variable set' object then my worry is that this whole object (containing all
the local variables for that scope) may be held while any closure exists
that makes reference to even one variable in that scope.

I don't know how the new lexical scope is implemented... which is why I'm
hoping someone who knows the new internals might tell me what's going on.

If it *does* prevent GCing of inaccessible objects then that needs to be
mentioned in the manual.

*cheers*
Peter Hill