From: Tijs van Bakel
Subject: how to finalize objects? (CLOS)
Date: 
Message-ID: <m2k8cx1ozo.fsf@casema.net>
Hello,

Is there a way to hook functions to the destruction process of CLOS
instances?  CMUCL supports finalization for ordinary lisp objects, and
I am nearly convinced that there is no portable way to do this, but
perhaps CLOS supports this?


I am working on a common lisp wrapper around the libggi [1] graphics
library, to build a simple and flexible GUI system [2].

For this, I am using structures in C which hold relevant data for
images (width, height, bitdepth, a pointer into a memory area), and
refer to these from lisp by means of an integer identifier value.
Memory is allocated in C, and it would be handy if this was freed
automatically when image handles are no longer in use.  The same idea
is applied for color palettes, input device events and display data.
The image handles are wrapped in CLOS classes which hide all FFI code.

Perhaps the entire design is lacking and could be improved?


[1] ggi stands for General Graphics Interface.  libggi is the core
library of the GGI project, and allows running the same graphical
program on various display targets.  See http://www.ggi-project.org/

[2] The current tarball of my experiment is available from
http://vengeance.et.tudelft.nl/~smoke/ecfh-gui/, and requires both
libggi and cmucl to compile.


Thanks in advance,
-- 
Tijs van Bakel, <·····@casema.net>
From: Barry Margolin
Subject: Re: how to finalize objects? (CLOS)
Date: 
Message-ID: <8lur5.10$j55.641@burlma1-snr2>
In article <··············@casema.net>,
Tijs van Bakel <·····@casema.net> wrote:
>Is there a way to hook functions to the destruction process of CLOS
>instances?  CMUCL supports finalization for ordinary lisp objects, and
>I am nearly convinced that there is no portable way to do this, but
>perhaps CLOS supports this?

No, there is no portable finalization mechanism.  But the
implementation-dependent mechanisms should work just as well for CLOS
instances as they do for any other Lisp data.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.