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] |
Doug Evans <devans@cygnus.com> writes: > I have an application that does the following in C: > > gh_new_procedure4_0 ("foo", foo); > > and later [but still in the same function call] does > > foo_ptr = &CDR(scm_permanent_object (scm_intern ("foo", 3))); > scm_apply (*foo_ptr, ...); > > The problem is that "foo" is undefined when calling scm_apply > (*foo_ptr == SCM_UNDEFINED). > > This used to work in 1.2 and I'm wondering if I've bumped into > an incompatibility since switching to 1.3. > > I've traced things to the point that gh_new_procedure4_0 calls > scm_sysintern and it returns something different than the subsequent > scm_intern call does. [Maybe the two foo's end up in different modules.] > > Does this ring a bell? Ding-a-ling. Yup, your stuff got put into a module that's different than the one scm_intern is querying. If I remember correctly (a dodgy proposition), gh_new_procedureXXX puts stuff into module (guile-user), but scm_intern returns something looked up in the-root-module, thus the symptom you are seeing. I use code like this to find and call out to a procedure in a particular module. (There are better (i.e. much faster) ways to do this, but this has been sufficient for my purposes so far). Also, I understand that CVS versions of guile have C level access to the module system, so the problem should go away soon. I'll add this to the guile FAQ that I'm working on (nearly ready for an early release). -russ static SCM make_callout(char *callout, SCM ls) { SCM proc; char buf[512]; sprintf(buf, "(module-ref (resolve-module '(guile-user)) '%s)", callout); proc = gh_eval_str(buf); if (proc == SCM_UNDEFINED) { printf("callout error: lookup failed for '%s'\n", callout); return SCM_UNDEFINED; } else { return scm_apply(proc, ls, SCM_EOL); } } -- Why be difficult when, with a bit of effort, you could be impossible?