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] |
Etienne Bernard <eb@via.ecp.fr> writes: > Hello > > I'm using Guile from my C program, and I use scm_make_regexp to create a > regexp SCM object: > > SCM r = scm_make_regexp(regex, > gh_list(gh_lookup("regexp/icase"), > SCM_UNDEFINED)); > > I get strange errors when I call scm_regexp_exec which makes me think that > the regexp got garbage collected somewhere: > > ERROR: In procedure regexp-exec: > ERROR: Wrong type argument in position 1: #<unknown-type (0x7f . > 0x4024a480) @ 0x4024a488> > > (first argument of scm_regexp_exec was r) > > Is this error really related to garbage collection, and what is then the > means to protect my newly created object ? Looks like it could be. What happens sometimes is that the compiler is optimizing away the SCM value, so that the gc can miss it. What you can do is scm_remember(&r), or, if the function returns something, call return scm_return_first(something, r) (these are both defined in gc.c; they don't do anything, but the presence of r later on means that the compiler can't optimize it away). > Where can I get more information on Guile 1.3 garbage collection ? gc.c ;) Actually, the documentation that comes with scm is also pretty good, since guile isn't that far removed from scm in some places; some of the problems that can come up are addressed in the extending scm section. I'm not sure if much about the gc is present in the partial documentation you can get via cvs. I have some notes up on the generational gc that I'm working on at http://home.thezone.net/~gharvey/guile/guile.html that sort of skirt around the current implementation, but there isn't really anything on the hard implementation details of the current gc there... so maybe it's not that useful, but shameless plugs are a bit of fun :) -- Greg