lua-users home
lua-l archive

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


> Now this doesn't seem such a severe problem, but it DOES imply that
> the __gc metamethod has to have some userdata-specific way of flagging
> a userdata as unusable once it is finalized, so that any post-
> finalization method-call on this userdata will be able to check this
> flag[1] and return harmlessly.

We think it is quite easy for the programmer to implement this flag
in the most appropriate way for her particular needs. Frequently an
object may be "explicitly finalized" (e.g., a file may be closed by an
explicit call), so the programmer has to do this flagging anyway.  (In
the previous example, Lua sets the FILE* to NULL to flag that the file
is closed, that is, finalized.)

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)?

-- Roberto