lua-users home
lua-l archive

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

Adam D. Moss wrote:
> Well... having asked about this before, I got the reply that using a
> Lua function as a finalizer is fully supported, IIRC.  Certainly I do
> this extensively without conspicuous problems.

Yeah, but setmetatable() doesn't work on userdata, and __gc *only* works on
userdata, which means that in order to do it you have to go via C. Which means
you have to be really serious to do it.

IIRC, Lua follows similar semantics to Java --- finalisers are only ever
called once, which means that if an object is resurrected and then garbage
collected again, it won't be finalised again. (Now I think of it, if your
finaliser is running Lua code it must be briefly resurrected, since 'self'
must be referenced.)

╭─┈David Given┈──McQ─╮ "...electrons, nuclei and other particles are good
│┈┈┈┈┈│ approximations to perfectly elastic spherical
│┈(┈│ cows." --- David M. Palmer on r.a.sf.c

Attachment: signature.asc
Description: OpenPGP digital signature