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

Re: clos destructors



>Something I can't find any reference to in the clos literature is a
>destructor function.  For standard LISP objects I don't need it, since
>GC takes care of this for me, but what if my objects contain Macintosh
>records (or some other non-lisp data structure)?  I need to deallocate
>such beasts before the object gets destroyed.
>         Jeffrey

This is usually called finalization. One general form of finalization is
to be able to declare that an object is finalizeable and that a
user-supplied function will be called with that object as a single
argument if the object would otherwise be garbage. The user function
can perform any cleanup it wishes, including making the object no longer
be garbage. If the object is still garbage at the next garbage
collection it will be collected. MCL does not support this kind
of general finalization. It DOES have an undocumented non-general
finalization for MACPTRs. If a MACPTR is created in a special way,
the garbage collector will call one of #_DisposePtr, #_DisposeHandle,
#_DisposeWindow, or #_DisposeGWorld on it before collecting its space.
I'll provide documentation for this feature if anyone is interested,
but beware, it may disappear or change radically in a future release
(we aren't planning such a change for 2.1).