[cffi-devel] CLisp finalizers

Marco Gidde marco.gidde at tiscali.de
Thu Feb 15 19:20:01 UTC 2007


"Luís Oliveira" <luismbo at gmail.com> writes:

> On 04/02/07, Marco Gidde <marco.gidde at tiscali.de> wrote:
>> While this code isn't as short and elegant as the original code, at
>> least it works ;-)
>
> Indeed it does. It passes the trivial-garbage tests without crashing. Thanks!
>
> Anyway, I didn't feel like changing and testing the finalization code
> in both CFFI and trivial-garbage (what was I thinking?) so I just
> wiped out CFFI's finalization code. People can use trivial-garbage if
> they're interested in portable finalizers:
> <http://cliki.net/trivial-garbage>

While I would like to see the finalizer code in CFFI because I never
felt like using them in another context, it is certainly better to
keep the code consistent in only one place.

And for that matter: when ECL is compiled with the boehm garbage
collector (is it even possible without?) the following code should
work a bit better than the simple ERROR :-):


(defun finalize (object function)
  #-boehm-gc (error "ECLli does not support finalizers.")
  #+boehm-gc
  (let ((old-finalizer (si:get-finalizer object)))
    (si:set-finalizer object
		      (if old-finalizer
			  (lambda (obj)
			    (funcall function)
			    (funcall old-finalizer obj))
			  (lambda (obj)
			    (funcall function))))))

(defun cancel-finalization (object)
  #-boehm-gc (error "ECLli does not support finalizers.")
  #+boehm-gc (si:set-finalizer object nil))


Just noticed that there is no ECL specific code in trivial-garbage.
Any ideas where this code should be placed now?


Regards,

Marco



More information about the cffi-devel mailing list