unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* bug in "imports obarray"?
@ 2010-04-07 22:13 Andy Wingo
  2010-04-08 20:47 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Wingo @ 2010-04-07 22:13 UTC (permalink / raw)
  To: guile-devel

Hi,

Consider the following module:

    (define-module (ice-9 curried-definitions)
      #:replace ((cdefine . define)
                 (cdefine* . define*)))

    (define-syntax cdefine
      (syntax-rules ()
        ((_ ((head . tail) . rest) body body* ...)
         (cdefine (head . tail)
           (lambda rest body body* ...)))
        ((_ (head . rest) body body* ...)
         (define head
           (lambda rest body body* ...)))))

    (define-syntax cdefine*
      (syntax-rules ()
        ((_ ((head . tail) . rest) body body* ...)
         (cdefine* (head . tail)
           (lambda* rest body body* ...)))
        ((_ (head . rest) body body* ...)
         (define* head
           (lambda* rest body body* ...)))))


If, at the repl, I do a (use-modules (ice-9 curried-definitions)), I
would expect my `define' to recognize the currying syntax.

What in fact happens, at my repl at least, is that though the module is
correctly added to the imports list, when looking for the value for
`define' in `(define ((foo)) 42)' we hit the memoized case in
module_imported_variable:

    /* Lookup SYM as an imported variable of MODULE.  */
    static inline SCM
    module_imported_variable (SCM module, SCM sym)
    {
    #define SCM_BOUND_THING_P scm_is_true
      register SCM var, imports;

      /* Search cached imported bindings.  */
      imports = SCM_MODULE_IMPORT_OBARRAY (module);
      var = scm_hashq_ref (imports, sym, SCM_UNDEFINED);
      if (SCM_BOUND_THING_P (var))
        return var;
here ^^

      {
        /* Search the use list for yet uncached imported bindings, possibly
           resolving duplicates as needed and caching the result in the import
           obarray.  */
        ...

I'm pretty sure this is a bug. We should have module-use! clear entries
from the cache -- all entries, probably. The normal case is for all
module-use! statements to be executed before before the module is made
current.

This could affect any cached variables in procedures, but I think we can
ignore that in this case.

Andy
-- 
http://wingolog.org/




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bug in "imports obarray"?
  2010-04-07 22:13 bug in "imports obarray"? Andy Wingo
@ 2010-04-08 20:47 ` Ludovic Courtès
  2010-04-08 22:12   ` Andy Wingo
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2010-04-08 20:47 UTC (permalink / raw)
  To: guile-devel

Hello,

Andy Wingo <wingo@pobox.com> writes:

> I'm pretty sure this is a bug. We should have module-use! clear entries
> from the cache -- all entries, probably. The normal case is for all
> module-use! statements to be executed before before the module is made
> current.

You must be right.  The problem doesn’t occur when processing a single
define-module or use-modules clause, because obviously the imported
binding cache is still empty at that point.

Thanks,
Ludo’.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bug in "imports obarray"?
  2010-04-08 20:47 ` Ludovic Courtès
@ 2010-04-08 22:12   ` Andy Wingo
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2010-04-08 22:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

Hi!

On Thu 08 Apr 2010 22:47, ludo@gnu.org (Ludovic Courtès) writes:

> Andy Wingo <wingo@pobox.com> writes:
>
>> I'm pretty sure this is a bug. We should have module-use! clear entries
>> from the cache -- all entries, probably. The normal case is for all
>> module-use! statements to be executed before before the module is made
>> current.
>
> You must be right.  The problem doesn’t occur when processing a single
> define-module or use-modules clause, because obviously the imported
> binding cache is still empty at that point.

I'm glad you concur, selfishly, as I don't need to revert any patches
now :)

Thanks for the review!

Andy
-- 
http://wingolog.org/




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-08 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-07 22:13 bug in "imports obarray"? Andy Wingo
2010-04-08 20:47 ` Ludovic Courtès
2010-04-08 22:12   ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).