GNU bug report logs - #47084
Guile 3.0 - The module-use! 'target' functionality is broken

Previous Next

Package: guile;

Reported by: David Pirotte <david <at> altosw.be>

Date: Fri, 12 Mar 2021 03:18:01 UTC

Severity: normal

To reply to this bug, email your comments to 47084 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#47084; Package guile. (Fri, 12 Mar 2021 03:18:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Pirotte <david <at> altosw.be>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Fri, 12 Mar 2021 03:18:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: <bug-guile <at> gnu.org>
Subject: Guile 3.0 - The module-use! 'target' functionality is broken
Date: Fri, 12 Mar 2021 00:17:38 -0300
[Message part 1 (text/plain, inline)]
Hello,

	Guile 3.0
	The module-use! 'target' functionality is broken

The code of module-use! itself didn't change, and call(s) to the
procedure work(s) fine, but the functionality it is supposed to
provide is broken.

To reproduce, save the following minimalist module somewhere:

;; start here
(define-module (a)
  #:use-module (srfi srfi-1))

(eval-when (expand load eval)
  (module-use! (module-public-interface (current-module))
               (resolve-interface '(srfi srfi-1))))
;; end here

	;; then, fire a 3.0 repl:
	(add-to-load-path "/your/path")
	,use (a)
	map

	[ below, my attempts using Guile 3.0.4.3-e076a5, then Guile
	[ 2.2.7.2-a5875-dirty to compare.

Fwiw:

	(a) G-Golf extensively relies on the module-use! functionality
'in general', and in particular, on its 'dynamic' implementation - that
is, the public interface of a module that has been 'module-used'
may evolve in time (at the 'essence' of any GI dynamic binding);

	(b) just like for the minimalist module (a) above, but it will
do so 'dynamically', G-Golf needs that the public interface of a
module that has been 'module-used' may re-export-and-replace a guile
core procedure (generally promoted as a generic function, with the core
proc as its default method).

Thanks,
David


GNU Guile 3.0.4.3-e076a5
...
scheme@(guile-user)> (add-to-load-path "/home/david/alto/projects/g-golf/3.0")
scheme@(guile-user)> ,use (a)
;;; compiling /home/david/alto/projects/g-golf/3.0/a.scm
;;; compiled /home/david/.cache/guile/ccache/3.0-LE-8-4.3/usr/alto/projects/g-golf/3.0/a.scm.go
scheme@(guile-user)> map
WARNING: (guile-user): imported module (a) overrides core binding `map'
WARNING: (guile-user): `map' imported from both (guile) and (a)
WARNING: (guile-user): imported module (a) overrides core binding `map'
WARNING: (guile-user): `map' imported from both (guile) and (a)
;;; <unknown-location>: warning: possibly unbound variable `map'
WARNING: (guile-user): imported module (a) overrides core binding `map'
WARNING: (guile-user): `map' imported from both (guile) and (a)
WARNING: (guile-user): imported module (a) overrides core binding `map'
WARNING: (guile-user): `map' imported from both (guile) and (a)
ice-9/boot-9.scm:1670:16: In procedure raise-exception:
Unbound variable: map

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]>


GNU Guile 2.2.7.2-a5875-dirty
...
scheme@(guile-user)> (add-to-load-path "/home/david/alto/projects/g-golf/3.0")
scheme@(guile-user)> ,use (a)
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/david/alto/projects/g-golf/3.0/a.scm
;;; compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.A/usr/alto/projects/g-golf/3.0/a.scm.go
scheme@(guile-user)> map
$2 = #<procedure map (f l) | (f l1 l2) | (f l1 . rest)>
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#47084; Package guile. (Mon, 03 May 2021 04:27:01 GMT) Full text and rfc822 format available.

Message #8 received at 47084 <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: 47084 <at> debbugs.gnu.org
Subject: Re: bug#47084: Guile 3.0 - The module-use! 'target' functionality
 is broken
Date: Mon, 3 May 2021 01:26:41 -0300
[Message part 1 (text/plain, inline)]
Hello,

> ...
> (define-module (a)
>   #:use-module (srfi srfi-1))

> (eval-when (expand load eval)
>   (module-use! (module-public-interface (current-module))
>                (resolve-interface '(srfi srfi-1))))
> ...

Commit 19f38a38fde7da5fbcf29d0ebc4574e993210110 fixes the
bug, many thanks.

Now, I have a question related to 'new' warnings though - I say 'new'
because there are no warnings in 2.2 - for which I don't see how one
can resolve those, unless mute them all by calling
default-duplicate-binding-handler and remove warn-override-core
and warn from the default list.

Here is a example, so one can reproduce and maybe give us some
hints:

;;; module (a) starts here
(define-module (foo)
  #:use-module (srfi srfi-1))

(eval-when (expand load eval)
  (module-use! (module-public-interface (current-module))
               (resolve-interface '(srfi srfi-1))))

(for-each display '(1 2 3 4))
(newline)
;;; module (foo) ends here


;;; file bar.scm starts here - not a module, just a file
(use-modules (foo))

#;(eval-when (expand load eval)
  (default-duplicate-binding-handler
    '(replace last)))

(for-each display '(5 6 7 8))
(newline)

;; drop the two above module/file somwhere

;;; now, fire geiser and
(add-to-load-path "/your/path")
(load "/your/path/bar.scm")

;; you should see that there is no warning 'from (foo)', but two
;; warnings

	WARNING: (guile-user): imported module (a) overrides core
	binding `for-each'

;; 'from the bar.scm file (one when it compiles, one when it 'runs' ...
;; if you start a new session, then there should be one warning only ...

Now, if we uncomment the eval-when in bar.scm and try again, all is
fine

But i wish the module-use! interface/internals would be enhanced so
that it does the same thing for module-use! then what is done simply
using #:use-module... and allow us to keep warn-override-core and warn
in the default-duplicate-binding-handler list ... not sure i made
myself clear, but trying :)

David




















[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#47084; Package guile. (Tue, 04 May 2021 04:38:01 GMT) Full text and rfc822 format available.

Message #11 received at 47084 <at> debbugs.gnu.org (full text, mbox):

From: David Pirotte <david <at> altosw.be>
To: 47084 <at> debbugs.gnu.org
Subject: Re: bug#47084: Guile 3.0 - The module-use! 'target' functionality
 is broken
Date: Tue, 4 May 2021 01:37:33 -0300
[Message part 1 (text/plain, inline)]
Hello,

> ...
> Commit 19f38a38fde7da5fbcf29d0ebc4574e993210110 fixes the
> bug, many thanks.

> Now, I have a question related to 'new' warnings though - I say 'new'
> because there are no warnings in 2.2 - for which I don't see how one
> can resolve those, unless mute them all by calling
> default-duplicate-binding-handler and remove warn-override-core
> and warn from the default list.

The proper way to stop these warnings is to add a
#:re-export-and-replace clause to the module definition of the module
that calls module-use! - I didn't think I had to do this because we
didn't have to using 2.2 (nor #:re-export nor #:replace, within the
context of module-use! that is, and the #:re-export-and-replace clause
is new to 3.0) - like this:

;;; module (a) starts here
(define-module (foo)
  #:use-module (srfi srfi-1))
  #:re-export-and-replace (for-each))

(eval-when (expand load eval)
  (module-use! (module-public-interface (current-module))
               (resolve-interface '(srfi srfi-1))))
;;; module (foo) ends here

Now the (bar) module or bar.scm file example file may skip the call to
default-duplicate-binding-handler:

;;; file bar.scm starts here
(use-modules (foo))
    
(for-each display '(5 6 7 8))
(newline)
;; file bar.scm stops here 

;; drop the two above module/file somwhere

;;; now, fire geiser and
(add-to-load-path "/your/path")
(load "/your/path/bar.scm")

;; you shouldn't see any warnings anymore...

David
[Message part 2 (application/pgp-signature, inline)]

This bug report was last modified 3 years and 239 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.