From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.bugs Subject: [PATCH] Use module identity to filter for existing modules Date: Wed, 02 Mar 2011 17:54:58 +0100 Message-ID: <87oc5txy1p.fsf@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1299084940 30103 80.91.229.12 (2 Mar 2011 16:55:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 2 Mar 2011 16:55:40 +0000 (UTC) To: Guile Bugs Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Mar 02 17:55:36 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PupKo-0003id-Kc for guile-bugs@m.gmane.org; Wed, 02 Mar 2011 17:55:34 +0100 Original-Received: from localhost ([127.0.0.1]:41714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PupKo-00072S-42 for guile-bugs@m.gmane.org; Wed, 02 Mar 2011 11:55:34 -0500 Original-Received: from [140.186.70.92] (port=50784 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PupKd-000712-HY for bug-guile@gnu.org; Wed, 02 Mar 2011 11:55:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PupKc-0002Hn-47 for bug-guile@gnu.org; Wed, 02 Mar 2011 11:55:23 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:48557) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PupKb-0002HM-LP for bug-guile@gnu.org; Wed, 02 Mar 2011 11:55:22 -0500 Original-Received: (qmail invoked by alias); 02 Mar 2011 16:55:13 -0000 Original-Received: from 83-215-154-5.hage.dyn.salzburg-online.at (EHLO nathot.lan) [83.215.154.5] by mail.gmx.net (mp056) with SMTP; 02 Mar 2011 17:55:13 +0100 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX19FsltIxOFF2pUIlrRO0ifrH0n+g3HLThJwjUwWuO Hbx2NSX07tFu79 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by nathot.lan (Postfix) with ESMTP id 82E5A3A68F for ; Wed, 2 Mar 2011 17:55:03 +0100 (CET) Original-Received: from nathot.lan ([127.0.0.1]) by localhost (nathot.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xhXAAPQ2eL+L for ; Wed, 2 Mar 2011 17:54:59 +0100 (CET) Original-Received: from delenn.lan (delenn.lan [192.168.3.11]) by nathot.lan (Postfix) with ESMTP id F20F53A685 for ; Wed, 2 Mar 2011 17:54:58 +0100 (CET) Original-Received: by delenn.lan (Postfix, from userid 1000) id B649D2C00C3; Wed, 2 Mar 2011 17:54:58 +0100 (CET) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.22 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5255 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=fix-module-use.diff From: Andreas Rottmann 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) --=-=-= Content-Type: text/plain Regards, Rotty -- Andreas Rottmann -- --=-=-=--