This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SCM objects on the heap?



> Am I right in assuming that SCM objects are only protected from gc as long
> as they are on the stack and not if they are on the heap?

That's right.  Guile doesn't know how to walk your data structures;
you have to tell it about them somehow.  There are certainly ways to
do this.

You could make a list known to the collector (protected via
scm_permanent_object) and add/remove your Scheme objects to/from it it
when your C++ object is created/destroyed.

SMOBs are another way to get the collector to call some of your code
at collection time, but if your C++ objects are not meant to be
managed by Scheme code, this might be a bit clumsy.