From: Andreas Rottmann <a.rottmann@gmx.at>
To: Guile Bugs <bug-guile@gnu.org>
Subject: [PATCH] Use module identity to filter for existing modules
Date: Wed, 02 Mar 2011 17:54:58 +0100 [thread overview]
Message-ID: <87oc5txy1p.fsf@gmx.at> (raw)
[-- 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/>
next reply other threads:[~2011-03-02 16:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-02 16:54 Andreas Rottmann [this message]
2011-03-03 10:29 ` [PATCH] Use module identity to filter for existing modules Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oc5txy1p.fsf@gmx.at \
--to=a.rottmann@gmx.at \
--cc=bug-guile@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).