This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
global objects in C
- To: <guile@sourceware.cygnus.com>
- Subject: global objects in C
- From: "Keisuke Nishida" <kei@psn.net>
- Date: Wed, 11 Aug 1999 00:45:46 -0400
Hi,
I would like to manage some scheme objects by global variables in C.
That is, I would like to write like this:
SCM global_stack;
init_global_stack ()
{
global_stack = SCM_EOL;
}
stack_push (SCM obj)
{
global_stack = scm_cons (obj, global_stack);
}
stack_pop ()
{
SCM obj = SCM_CAR (global_stack);
global_stack = SCM_CDR (global_stack);
return obj;
}
I suppose I have to protect the variable global_stack from GC
by pointer, like:
scm_protect_pointer (&global_stack);
before using global_stack. Is there any way to do this?
Also, I would like to connect global_stack and a scheme symbol
`global-stack' seamlessly. That is, "global_stack = ...;" in C
changes the value of global-stack, and "(set! global-stack ...)"
in Scheme changes the value of global_stack. I guess I can do
this by modifying the evaluater, as Emacs does, but I wonder if
there is already excellent way to do that.
Thanks in advance.