James A. Crippen wrote:
 >
 > I have heard that only CMUCL appears to have such a function.
 >
 >
 > Which is fine, because although EXT:FINALIZE is really useful, it
 > doesn't work in all cases for me, so I'm just going to have to write
 > C-like code to track when and where to free alien objects...  Bleah.

MCL has that functionality, though it calls it "termination".

   (defun foo-dispose (o)
     ;; Free the underlying resources
     ...)

   (ccl:terminate-when-unreachable foo-obj #'foo-dispose)

MCL's implementation is pretty slick.  It passes the object that is
eligible for termination to the termination function, for one thing,
and the termination function can store away a reference to the object,
which will then prevent the object from being GCed.

You can also call ccl:cancel-terminate-when-unreachable to stop
termination for an object.

It's really handy in the right situation, for sure.

(It looks like it's in OpenMCL, too.  ccl/level-1/l1-stack-groups.lisp
has the code and a description of the API.)


John Wiseman


Reply via email to