lua-users home
lua-l archive

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

[Umm... before my little message here I have a rant regarding certain posts
to lua-l.  If you find yourself posting a message that consists of 80%
quoted text, 15% signature and pgp info, and 5% barely Lua-related content,
please consider looking up some FAQ's on mailing list etiquette.]

Edgar Toernig wrote:
> After some talk with John some weeks ago I made weakrefs part of
> Sol.  There's one additional thing I changed.  Instead of calling
> the GC method for NIL after garbage collection I added two call-

It's nice to be able to hook from Lua.  I had written the following to the
Lua guys when I submitted my LTN:

    One of the issues I ran into was that I would have liked to
    be able to chain to the gc cycle from within Lua.  Since the
    gc event on nil does not represent actual destruction of an
    object, I'm wondering if it wouldn't be harmless to allow
    that tag method to be defined from Lua.  A recursion gate
    could be used to prevent the event being called while inside
    the tag method.

Your solution is just as good.  By the way, would anything funky happen if a
gc cycle happened within your hooks?

> One thing I'm still thinking about is adding callbacks for gc'ed
> refs itself.

Callbacks are nice too.  Of course you can implement them on top of the
current weak ref interface but scanning is still required as you say.
However if you implement low-level callbacks during the gc cycle and export
this to Lua won't it cause some danger?  It falls in the same category as gc
events for tables.