guile-user
[Top][All Lists]
Advanced

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

Re: Is my procedure getting GCed?


From: Michael Livshin
Subject: Re: Is my procedure getting GCed?
Date: 01 May 2001 19:59:01 +0300
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Copyleft)

Brett Viren <address@hidden> writes:

> The program has a C++ class which stores a Guile procedure as an SCM
> which it gets at construction:
> 
>     class ScalarBC {
>         // ...
>         SCM fProc;
>     }
>     // ...
>     ScalarBC my_sbc(gh_eval_str("(lambda () (random:uniform))"));

the Guile GC only knows about the calling stack and the registers.

if all the instances of ScalarBC are automatic (i.e. sit on the
stack), then there should be no problem.  but if you `new' them or
they are static, then you definitely should inform Guile about the
fProc field.

try adding this to the constructor:

scm_protect_object (fProc); // once fProc is intialized, of course

and this to the destructor:

scm_unprotect_object (fProc);

hth, never mind the Totally Random signature,
--mike

-- 
... it's just that in C++ and the like, you don't trust _anybody_,
and in CLOS you basically trust everybody.  the practical result
is that thieves and bums use C++ and nice people use CLOS.
                -- Erik Naggum




reply via email to

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