unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Use module identity to filter for existing modules
@ 2011-03-02 16:54 Andreas Rottmann
  2011-03-03 10:29 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rottmann @ 2011-03-02 16:54 UTC (permalink / raw)
  To: Guile Bugs

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

Hi!

As discussed on IRC, here is a fix that makes R6RS's `import' work again
when importing multiple times from the same library.  See the patch
header for details.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-module-use.diff --]
[-- Type: text/x-diff, Size: 2772 bytes --]

From: Andreas Rottmann <a.rottmann@gmx.at>
Subject: Use module identity to filter for existing modules

This fixes a problem with R6RS's `import' in particuliar: when importing
a subset of a library/module, the interface created for that purpose
inherits the name of the module it is derived from.  The low-level
primitives that are used for importing would then disregard earlier
imports from the same module.

An example for this bug can be seen with the following library
definition:

(library (test-guile2)
  (export foo)
  (import (only (rnrs base) define)
          (only (rnrs base) error))

  (define (foo . args)
    #t))

In the above, the import of `define' would be disregarded when `error'
is imported, thus leading to a syntax error, since `(foo . args)' is
treated as an application, since the binding of `define' would be not
present.


* module/ice-9/boot-9.scm (module-use!): Remove the filtering of the
  existing imports of the module by name; a check for identity is
  already done beforehand.
  (module-use-interfaces!): Filter the existing imports by identity
  instead of filtering them by their names.

---
 module/ice-9/boot-9.scm |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 9f621d9..fbad99b 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -1987,13 +1987,8 @@ VALUE."
         ;; Newly used modules must be appended rather than consed, so that
         ;; `module-variable' traverses the use list starting from the first
         ;; used module.
-        (set-module-uses! module
-                          (append (filter (lambda (m)
-                                            (not
-                                             (equal? (module-name m)
-                                                     (module-name interface))))
-                                          (module-uses module))
-                                  (list interface)))
+        (set-module-uses! module (append (module-uses module)
+                                         (list interface)))
         (hash-clear! (module-import-obarray module))
         (module-modified module))))
 
@@ -2004,8 +1999,7 @@ VALUE."
 (define (module-use-interfaces! module interfaces)
   (let ((prev (filter (lambda (used)
                         (and-map (lambda (iface)
-                                   (not (equal? (module-name used)
-                                                (module-name iface))))
+                                   (not (eq? used iface)))
                                  interfaces))
                       (module-uses module))))
     (set-module-uses! module
-- 
tg: (58b1db5..) t/fix-module-use (depends on: stable-2.0)

[-- Attachment #3: Type: text/plain, Size: 63 bytes --]


Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>

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

* Re: [PATCH] Use module identity to filter for existing modules
  2011-03-02 16:54 [PATCH] Use module identity to filter for existing modules Andreas Rottmann
@ 2011-03-03 10:29 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2011-03-03 10:29 UTC (permalink / raw)
  To: Andreas Rottmann; +Cc: Guile Bugs

Hi,

On Wed 02 Mar 2011 17:54, Andreas Rottmann <a.rottmann@gmx.at> writes:

> As discussed on IRC, here is a fix that makes R6RS's `import' work again
> when importing multiple times from the same library.  See the patch
> header for details.

Applied, thanks.

Andy
-- 
http://wingolog.org/



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

end of thread, other threads:[~2011-03-03 10:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02 16:54 [PATCH] Use module identity to filter for existing modules Andreas Rottmann
2011-03-03 10:29 ` 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).