[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing lambda bindings to C for use as callback
From: |
Marc Singer |
Subject: |
Re: Passing lambda bindings to C for use as callback |
Date: |
Mon, 25 Nov 2002 19:22:23 -0800 |
User-agent: |
Mutt/1.4i |
On Mon, Nov 25, 2002 at 06:45:45PM -0800, Marc Singer wrote:
> ...works for a while and then the gh_apply fails stating that the
> callback function is missing. My guess is that this callback, an
> anonymous lambda binding, is being garbage collected.
>
> I've found a reference to this problem and some solution being made
> for tcl. Will someone share with me either the solution or a place to
> find it?
I found the answer by browsing an old CVS archive of the guile code.
Turned out to be quite easy.
1) On startup, I register a hook using scm_c_hook_add () for
scm_before_sweep_c_hook.
2) I store SCMs for active callbacks in one datastructure
3) When the hook procedure executes, it calls scm_gc_mark on each of
the callback SCMs.
Cake.