GNU bug report logs -
#15540
Circular module imports vs. #:select (2.0.9)
Previous Next
Reported by: ludo <at> gnu.org (Ludovic Courtès)
Date: Sun, 6 Oct 2013 19:43:02 UTC
Severity: normal
Done: Andy Wingo <wingo <at> pobox.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15540 in the body.
You can then email your comments to 15540 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#15540
; Package
guile
.
(Sun, 06 Oct 2013 19:43:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Sun, 06 Oct 2013 19:43:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Consider these two modules:
--8<---------------cut here---------------start------------->8---
(define-module (a) #:use-module (b) #:export (from-a))
(define from-a 1)
--8<---------------cut here---------------end--------------->8---
and:
--8<---------------cut here---------------start------------->8---
(define-module (b) #:use-module ((a) #:select (from-a)) #:export (from-b))
(define from-b 2)
--8<---------------cut here---------------end--------------->8---
This fails:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(a)
While executing meta-command:
ERROR: no binding `from-a' in module (a)
--8<---------------cut here---------------end--------------->8---
whereas this succeeds (starting from a fresh Guile):
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(b)
scheme@(guile-user)> from-b
$1 = 2
--8<---------------cut here---------------end--------------->8---
Problem is that ‘define-module*’ processes exports after imports.
What about a patch along these lines:
[Message part 2 (text/x-patch, inline)]
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index c825b35..24b8f4c 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2872,11 +2872,8 @@ VALUE."
(error "expected list of integers for version"))
(set-module-version! module version)
(set-module-version! (module-public-interface module) version)))
- (let ((imports (resolve-imports imports)))
(call-with-deferred-observers
(lambda ()
- (if (pair? imports)
- (module-use-interfaces! module imports))
(if (list-of valid-export? exports)
(if (pair? exports)
(module-export! module exports))
@@ -2885,6 +2882,9 @@ VALUE."
(if (pair? replacements)
(module-replace! module replacements))
(error "expected replacements to be a list of symbols or symbol pairs"))
+ (let ((imports (resolve-imports module)))
+ (if (pair? imports)
+ (module-use-interfaces! module imports)))
(if (list-of valid-export? re-exports)
(if (pair? re-exports)
(module-re-export! module re-exports))
@@ -2896,7 +2896,7 @@ VALUE."
;; handlers.
(if (pair? duplicates)
(let ((handlers (lookup-duplicates-handlers duplicates)))
- (set-module-duplicates-handlers! module handlers))))))
+ (set-module-duplicates-handlers! module handlers)))))
(if transformer
(if (and (pair? transformer) (list-of symbol? transformer))
[Message part 3 (text/plain, inline)]
Thanks,
Ludo’.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#15540
; Package
guile
.
(Tue, 08 Oct 2013 20:02:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 15540 <at> debbugs.gnu.org (full text, mbox):
Looks fine to me. Maybe it's worth adding a comment to the source to
mention why we do it that way. And of course, a test so we don't break
it in the future. :)
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
Information forwarded
to
bug-guile <at> gnu.org
:
bug#15540
; Package
guile
.
(Tue, 21 Jun 2016 11:09:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 15540 <at> debbugs.gnu.org (full text, mbox):
Yes!
As Ian notes this needs a test case. Some kind Guixer should fix up
this patch and send to Guile so that it lands before we release 2.0.12,
which should come any day now :-)
Andy
On Sun 06 Oct 2013 21:36, ludo <at> gnu.org (Ludovic Courtès) writes:
> Consider these two modules:
>
> (define-module (a) #:use-module (b) #:export (from-a))
> (define from-a 1)
>
> and:
>
> (define-module (b) #:use-module ((a) #:select (from-a)) #:export (from-b))
> (define from-b 2)
>
> This fails:
>
> scheme@(guile-user)> ,use(a)
> While executing meta-command:
> ERROR: no binding `from-a' in module (a)
>
> whereas this succeeds (starting from a fresh Guile):
>
> scheme@(guile-user)> ,use(b)
> scheme@(guile-user)> from-b
> $1 = 2
>
> Problem is that ‘define-module*’ processes exports after imports.
>
> What about a patch along these lines:
>
> diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
> index c825b35..24b8f4c 100644
> --- a/module/ice-9/boot-9.scm
> +++ b/module/ice-9/boot-9.scm
> @@ -2872,11 +2872,8 @@ VALUE."
> (error "expected list of integers for version"))
> (set-module-version! module version)
> (set-module-version! (module-public-interface module) version)))
> - (let ((imports (resolve-imports imports)))
> (call-with-deferred-observers
> (lambda ()
> - (if (pair? imports)
> - (module-use-interfaces! module imports))
> (if (list-of valid-export? exports)
> (if (pair? exports)
> (module-export! module exports))
> @@ -2885,6 +2882,9 @@ VALUE."
> (if (pair? replacements)
> (module-replace! module replacements))
> (error "expected replacements to be a list of symbols or symbol pairs"))
> + (let ((imports (resolve-imports module)))
> + (if (pair? imports)
> + (module-use-interfaces! module imports)))
> (if (list-of valid-export? re-exports)
> (if (pair? re-exports)
> (module-re-export! module re-exports))
> @@ -2896,7 +2896,7 @@ VALUE."
> ;; handlers.
> (if (pair? duplicates)
> (let ((handlers (lookup-duplicates-handlers duplicates)))
> - (set-module-duplicates-handlers! module handlers))))))
> + (set-module-duplicates-handlers! module handlers)))))
>
> (if transformer
> (if (and (pair? transformer) (list-of symbol? transformer))
>
> Thanks,
> Ludo’.
Reply sent
to
Andy Wingo <wingo <at> pobox.com>
:
You have taken responsibility.
(Tue, 28 Feb 2017 10:51:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
bug acknowledged by developer.
(Tue, 28 Feb 2017 10:51:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 15540-done <at> debbugs.gnu.org (full text, mbox):
On Sun 06 Oct 2013 21:36, ludo <at> gnu.org (Ludovic Courtès) writes:
> Consider these two modules:
>
> (define-module (a) #:use-module (b) #:export (from-a))
> (define from-a 1)
>
>
> and:
>
> (define-module (b) #:use-module ((a) #:select (from-a)) #:export (from-b))
> (define from-b 2)
>
>
> This fails:
>
> scheme@(guile-user)> ,use(a)
> While executing meta-command:
> ERROR: no binding `from-a' in module (a)
>
>
> whereas this succeeds (starting from a fresh Guile):
>
> scheme@(guile-user)> ,use(b)
> scheme@(guile-user)> from-b
> $1 = 2
>
> Problem is that ‘define-module*’ processes exports after imports.
Applied a version of your patch to master. Making the test was quite
tricky!
Andy
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 28 Mar 2017 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 2 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.