chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] [newbie] destroying foreign objects


From: Jim Ursetto
Subject: Re: [Chicken-users] [newbie] destroying foreign objects
Date: Sat, 30 Jan 2010 00:48:58 -0600


On Jan 30, 2010, at 12:22 AM, Marco Maggi wrote:
 I   am  skimming   through   Chicken's  documentation   to
understand what it  can do; is there a  way to automatically
apply a  finalisation function when  a pointer to  a foreign
object   (C  language   structure)  is   garbage  collected?
Something like guardians.

You could use set-finalizer! on the pointer object or whatever scheme object contains the raw C pointer. Does that answer your question? There should be some examples in the eggs, for example objc.

$ chicken-doc set-finalizer\!
path: (library set-finalizer!)
procedure: (set-finalizer! X PROC)

Registers a procedure of one argument `PROC`, that will be
called as soon as the non-immediate data object `X` is about to
be garbage-collected (with that object as its argument). Note that
the finalizer will '''not''' be called while interrupts are disabled.
This procedure returns `X`.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]