[Top][All Lists]

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

Calling scheme from C: problem with GC.

From: Alejandro Forero Cuervo
Subject: Calling scheme from C: problem with GC.
Date: Fri, 23 Nov 2001 10:33:36 -0500
User-agent: Mutt/1.2.5i

Hey there.

Just for the record, yesterday and today I finally got time to
continue my work on HB-Guile integration.  I still have a few details
that I need to improve but, in general terms, things are working.
I'll send an announcement as soon as I'm done and I'll then wait for
MJR to complain about the missing features.  :)

Anyway, I'm having a problem: I don't know how to tell the Guile's GC
that some of my C code depends on SCM objects that got passed to one
of my visible-from-Scheme C functions.

Before parsing a file with user-code, I define a hb-register function
that the user-code can call to register procedures for different
things.  The procedures passed to my hb-register function are stored
somewhere in my C structs for further use.  I need to tell Guile not
to destroy those SCM objects.

For instance, the user-code does:

  (hb-register "main" (lambda () (display "<html></html>")))

Guile calls the C procedure that I bound to hb-register which stores
its second parameter (the procedure) somewhere for latter use and
returns.  How do I inform Guile that it will be needed after the C
procedure returns?

One work around seems to be to have the user-code do something like:

    (define (main-func) (display "<html></html>"))
    (hb-register "main" main-func)

This way Guile seems not to free the SCM object since it has a name
bound to it (main-func).  However, in my previous example, things will
go bad since eventually Guile will free the procedure.

How can I solve this?

Thank you very much for your help.


The mere formulation of a problem is far more essential than its solution.
      -- Albert Einstein.

$0='!/sfldbi!yjoV0msfQ!sfiupob!utvK'x44;print map{("\e[7m \e[0m",chr ord
"219CC1CCC033E7E660198CCE4E66798303873CCE60F3387$F"#Don't you love Perl?

Attachment: pgpXn6qg9R1jv.pgp
Description: PGP signature

reply via email to

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