lua-users home
lua-l archive

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

Roberto Ierusalimschy wrote:
We think it is quite easy for the programmer to implement this flag
in the most appropriate way for her particular needs.

It isn't hard at all, though it is laborious and, I think,
unnecessary to do manually (is there ever a valid reason to
want to use the value of a post-finalization object from lua?).

Sorry to ask, but why can't you create B and C before A? If A needs
them, wouldn't be more natural to create them first? What happens
if there is an error while creating B (after A is already created)?

With some fiddling I'm sure I can change the creation order -- in this
case at least -- but without awareness of the subtleties of the issue I
didn't realize the hazards of not doing so, and it's a quite unintuitive
way of approaching this particular problem.

Object A is of a class W which requires subsystem X to be activated,
but subsystem X is quite expensive to have running so it is only
activated by the first call to the constructor on an object of class
W.  Subsystem X creates the two objects B,C upon activation,
thus they are created after object A.  Conversely (in an ideal
non-lua_close world) the finalization of the final object (in this
case A again) of class W causes subsystem X to be closed down,
requiring the use of objects B and C to do so.

Adam D. Moss   -