Gmane
Favicon
From: Edi Weitz <edi <at> agharta.de>
Subject: ADD-SPECIAL-FREE-ACTION
Newsgroups: gmane.lisp.lispworks.general
Date: 2004-08-30 07:27:13 GMT (4 years, 44 weeks, 4 hours and 15 minutes ago)
The doc entry for ADD-SPECIAL-FREE-ACTION says that its first and only
argument should be a function. However, after having been bitten by this
yesterday I'm pretty sure that the desired effect will only be achieved if
ADD-SPECIAL-FREE-ACTION is provided with a symbol denoting a function, i.e.

  (add-special-free-action 'foo)

will work while

  (add-special-free-action #'foo)

won't. I think this should be documented.

Also, I can't find a place where it's documented how FOO should look like. I
guess it takes one argument, namely the object which is about to be
garbage-collected, but there's no clear description in the docs about this.

Last point: There's a peculiar comment in opengl/vectors.lisp which says:

;;; using ADD-SPECIAL-FREE-ACTION and FLAG-SPECIAL-FREE-ACTION is not
normally
;;; recommended when using the FLI as
;;; 1. It can slow down the GC mechanism by adding overheads to objects to
cleanup.
;;; 2. Can have disastrous results if the allocated foreign object is
;;;    not cleaned up before an image save - data allocated by
;;;    fli:allocate-foreign-object is not persistent across image saves.

I don't understand this at all. To me it looks as if the parts of my code
dealing with external resources (like FLI stuff) are the prime candidates
for special free actions. Where am I suppposed to use special free actions
if not there?

In particular, yes, it may slow down GC but what has that to do with the
FLI? It will also slow down GC if the FLI is not involved, won't it?

And, for the second point, I thought that adding a special free action would
be a good measure to prevent such disastrous results from happening. Again,
I can't see why using these tools would be specifically bad here.

Comments?

Cheers,
Edi.