31.8. Finalization

Calling (EXT:FINALIZE object function) has the effect that when the specified object is being garbage-collected, (FUNCALL function object) will be executed.

Calling (EXT:FINALIZE object function guardian) has a similar effect, but only as long as the guardian has not been garbage-collected: when object is being garbage-collected, (FUNCALL function object guardian) will be executed. If the guardian is garbage-collected before object is, nothing happens.

Note

The time when the object is being garbage-collected is not defined deterministically. (Actually, it might possibly never occur.) It denotes a moment at which no references to object exist from other Lisp objects. When the function is called, object (and, possibly, guardian) enter the arena of live Lisp objects again.

No finalization request will be executed more than once.


These notes document CLISP version 2.49Last modified: 2010-07-07