[Top][All Lists]

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

Re: Doc--protecting guile entities defined in C

From: Christopher Cramer
Subject: Re: Doc--protecting guile entities defined in C
Date: Wed, 18 Jun 2003 17:57:43 -0500
User-agent: Mutt/1.2.5i

On Mon, Jun 02, 2003 at 10:46:58PM +0200, Pascal Cedraschi wrote:
> I have tried defining a global (in C) SCM variable
> and setting the symbol's name with `scm_str2symbol' but the symbol thus
> defined disappears unless I protect it (from the garbage collector?)
> with `scm_gc_protect_object'.  Is that right?

That is correct, although I think in most cases you should instead use
scm_permanent_object. scm_gc_protect_object should be used when you might
end up using scm_gc_unprotect_object later. The usual way of creating
a static symbol in C is:

        foo = scm_permanent_object(scm_str2symbol("foo"));

Basically whenever you store a Scheme value (whether a symbol or any
other data type) that isn't on the stack, you need to protect it.
Apparently, this isn't in the manual.

Christopher Cramer <address@hidden> <http://www.pyro.net/~crayc/>
"People said it couldn't be that our soldiers would do such things. Now
you read worse things in the mainstream media and people don't care. We
used to say that if only people know about it, it would stop. Now they
know about it, and it hasn't stopped." - Adam Keller

reply via email to

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