unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#47245: re-defining imported symbol to itself fails
@ 2021-03-18 16:51 Jan Nieuwenhuizen
  0 siblings, 0 replies; only message in thread
From: Jan Nieuwenhuizen @ 2021-03-18 16:51 UTC (permalink / raw)
  To: 47245

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

Hi!

Using the attached foo.scm and bar.scm, Guile 2.2 nicely redefines
%foo and %baz:

--8<---------------cut here---------------start------------->8---
$ guild compile -L . -o foo.go foo.scm
wrote `foo.go'
17:48:10 janneke@dundal:~/src/guile/master [env]
$ guild compile -L . -o bar.go bar.scm
wrote `bar.go'
17:48:12 janneke@dundal:~/src/guile/master [env]
$ guile -C . -c '(use-modules (bar))'
foo: "foo"
baz: "baz"
17:48:16 janneke@dundal:~/src/guile/master [env]
$ guile -C . -c '(use-modules (bar))'
foo: "foo"
baz: "baz"
--8<---------------cut here---------------end--------------->8---

Guile-3.0 sets %foo to *unspecified*:

--8<---------------cut here---------------start------------->8---
$ meta/build-env meta/guild compile -L . -o foo.go foo.scm
wrote `foo.go'
17:50:03 janneke@dundal:~/src/guile/master [env]
$ meta/build-env guild compile -L . -o bar.go bar.scm
wrote `bar.go'
17:50:10 janneke@dundal:~/src/guile/master [env]
$ meta/build-env meta/guile -C . -c '(use-modules (bar))'
foo: #<unspecified>
baz: "baz"
--8<---------------cut here---------------end--------------->8---

Greetings,
Janneke


[-- Attachment #2: foo.scm --]
[-- Type: application/octet-stream, Size: 61 bytes --]

(define-module (foo)
  #:export (%foo))

(define %foo "foo")

[-- Attachment #3: bar.scm --]
[-- Type: application/octet-stream, Size: 219 bytes --]

(define-module (bar)
  #:use-module (foo))

(define (bar?) #f)

(define %foo (if (bar?) "bar" %foo))

(format #t "foo: ~s\n" %foo)

(define %baz "baz")
(define %baz (if (bar?) "bar" %baz))

(format #t "baz: ~s\n" %baz)

[-- Attachment #4: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-18 16:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 16:51 bug#47245: re-defining imported symbol to itself fails Jan Nieuwenhuizen

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).