bug-guile
[Top][All Lists]
Advanced

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

[FIXED:] gh_lookup not seeing gh_new_procedure


From: Dirk Herrmann
Subject: [FIXED:] gh_lookup not seeing gh_new_procedure
Date: Fri, 29 Dec 2000 16:55:29 +0100 (MET)

On Tue, 7 Jan 1997, Dale P. Smith wrote:

> This is probably user error, but recent changes to guile cause this to
> print "val is undefined".  I probably need to use gh_module_lookup, but
> with what arguments?
> 
> Thanks!
>   -Dale
> 
> #include <guile/gh.h>
> 
> SCM
> foo()
> {
>   printf("inside foo()\n");
>   return SCM_UNDEFINED;
> }
> 
> int
> main()
> {
>   SCM val;
> 
>   scm_init_guile();
> 
>   gh_new_procedure0_0("foo", foo);
>   val = gh_lookup("foo");
>   if (val == SCM_UNDEFINED)
>     printf("val is undefined\n");
>   else
>     gh_call0(val);
>   return 0;
> }

Thanks for that bug report.  In fact, it was not a user error, but an
effect of the recent separation of symbols and bindings.  The problem lies
in the definition of root-module-closure/scm-module-closure in boot-9.scm.
These functions performed a call to (symbol-interned? #f s) to test if the
result is #t.  This call was redundant, because (symbol-interned? #f s)
_always_ returned #t.  However, after symbols and bindings got separated, 
(symbol-interned? #f s) would only return #t if there was actually a
binding for s.  Fixing this bug simple meant to remove the redundant
calls.  The patch is already in CVS.

However, you should be warned that you might nevertheless run into
problems with the combination of calls to gh_new_procedure and gh_lookup,
since gh_new_procedure will create a binding in the current module, while
gh_lookup will always look in the root module.  However, in your example
above this does not make a difference, since in the example the root
module is the current module.

Best regards,
Dirk Herrmann




reply via email to

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