lua-users home
lua-l archive

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


On Oct 30, 2002 at 04:10 -0300, Roberto Ierusalimschy wrote:
> > Does the Lua core always use the set* macros to change a Value's state?
> 
> Yes (or it should), but this is not enough. As we discussed for the
> stack, we still need some way to catch creation/destroying of references
> (and not only changes).

Good point.  If new Value objects are always initialized to nil, then
that should take care of creation.  I suppose that's not already being
done though.

For destruction of stack references, it can be safely deferred, like
we discussed.  So, in the GC's where this is necessary, it can be
deferred all the way until luaC_collect is called.  To get earlier
collection of things referred to by the stack, an explicit
lua_cleanstack() API could be added, or perhaps it could be done in
luaD_checkstack().  Basically, it needs to call setnilvalue() on all
entries of the stack above the current top.  So I think this stack
cleaning could easily be part of a GC patch -- it doesn't need to be
included in the core.

For destruction of non-stack references, it would suffice to set all
Values to nil with setnilvalue() when they are destroyed.  I suppose
this also is not being done currently, but then I haven't looked.

-- 
Thatcher Ulrich
http://tulrich.com