Thanks. I think that is the best solution. Paulo Jabardo
----- Mensagem original ---- De: Zbigniew <[EMAIL PROTECTED]> Para: Paulo Jabardo <[EMAIL PROTECTED]> Cc: [email protected] Enviadas: Terça-feira, 2 de Janeiro de 2007 21:24:22 Assunto: Re: [Chicken-users] Setting up hooks in garbage collection I would think that your make-gsi-XXX could use set-finalizer! like so: (set-finalizer! obj (lambda (x) (gsi-xxx-free x))) It assumes you're willing to wait for a major GC and that you are sure this pointer is not being used anywhere else, although you would have the latter issue with an explicit free. If you're going to use finalizers very heavily, I would suggest you call csi with -:d to activate debugging just so you can see how the finalization is happening. On 1/2/07, Paulo Jabardo <[EMAIL PROTECTED]> wrote: > I'm beginning to develop a chicken interface to the GNU scientific library > (gsl). Several numerical procedures involve an operation such as: > > gsl_XXX *ptr = gsl_XXX_alloc(...) > > ... > > gsl_XXX_free(ptr) > > > I would like to define a chicken variable that manages the pointer. But I > don't want to explicitely call the XXX_free function. Something like: > > (define resource (make-gsl-XXX ...)) > > When the garbage collector collects resource, it would automatically call the > function gsl_XXX_free (or a chicken wrapper of it). > > Is that even possible? > If it isn't could someone suggest a "schemish" approach to the problem? __________________________________________________ Fale com seus amigos de graça com o novo Yahoo! Messenger http://br.messenger.yahoo.com/ _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
