unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Passing lambda bindings to C for use as callback
@ 2002-11-26  2:45 Marc Singer
  2002-11-26  3:22 ` Marc Singer
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Singer @ 2002-11-26  2:45 UTC (permalink / raw)


...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?

Thanks.



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing lambda bindings to C for use as callback
  2002-11-26  2:45 Passing lambda bindings to C for use as callback Marc Singer
@ 2002-11-26  3:22 ` Marc Singer
  2002-11-26 12:10   ` Marius Vollmer
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Singer @ 2002-11-26  3:22 UTC (permalink / raw)


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.





_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing lambda bindings to C for use as callback
  2002-11-26  3:22 ` Marc Singer
@ 2002-11-26 12:10   ` Marius Vollmer
  2002-11-26 20:55     ` Marc Singer
  0 siblings, 1 reply; 5+ messages in thread
From: Marius Vollmer @ 2002-11-26 12:10 UTC (permalink / raw)
  Cc: guile-user

Marc Singer <elf@buici.com> writes:

> I found the answer by browsing an old CVS archive of the guile code.
> Turned out to be quite easy.

You can also pass the SCM objects that you want to protect globally to
the function scm_gc_protect_object.  Guile will then keep the data
structure for you.  You can unprotect such an object with
scm_gc_unprotect_object.  For objects that you wont ever unprotect you
can also use scm_permanent_object.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing lambda bindings to C for use as callback
  2002-11-26 12:10   ` Marius Vollmer
@ 2002-11-26 20:55     ` Marc Singer
  2002-11-26 21:56       ` Thien-Thi Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Singer @ 2002-11-26 20:55 UTC (permalink / raw)
  Cc: guile-user

On Tue, Nov 26, 2002 at 01:10:48PM +0100, Marius Vollmer wrote:
> You can also pass the SCM objects that you want to protect globally to
> the function scm_gc_protect_object.  Guile will then keep the data
> structure for you.  You can unprotect such an object with
> scm_gc_unprotect_object.  For objects that you wont ever unprotect you
> can also use scm_permanent_object.

Was this added after v1.4?


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing lambda bindings to C for use as callback
  2002-11-26 20:55     ` Marc Singer
@ 2002-11-26 21:56       ` Thien-Thi Nguyen
  0 siblings, 0 replies; 5+ messages in thread
From: Thien-Thi Nguyen @ 2002-11-26 21:56 UTC (permalink / raw)
  Cc: guile-user

   From: Marc Singer <elf@buici.com>
   Date: Tue, 26 Nov 2002 12:55:56 -0800

   Was this added after v1.4?

for these kind of questions, see:

 http://www.glug.org/snap/api/

where you can find a (dated) per-version scan and a (selectively
elaborated) diff matrix.  patches to improve scan methodology welcome.
(i'm slowly working towards .h scanning for a more complete picture.)

thi


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-11-26 21:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-26  2:45 Passing lambda bindings to C for use as callback Marc Singer
2002-11-26  3:22 ` Marc Singer
2002-11-26 12:10   ` Marius Vollmer
2002-11-26 20:55     ` Marc Singer
2002-11-26 21:56       ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).