ashinn / chibi-scheme

Official chibi-scheme repository
Other
1.22k stars 141 forks source link

Changes in exported identifiers are not seen in libraries that import them. #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

$ cat bar.sld
(define-library (bar)
  (export bar set-bar-to-two-and-display-bar!)
  (import (scheme base))
  (import (scheme write))
  (begin
    (define bar "one\n")
    (define (set-bar-to-two-and-display-bar!) (set! bar "two\n") (display bar))))
$ cat bar.scm 
(import (bar))
(import (scheme write))
(display bar)
(set-bar-to-two-and-display-bar!)
(display bar)
$ chibi-scheme bar.scm

What is the expected output? What do you see instead?

I expect to see "one", "two", and "two". Instead I see "one", "two", and "one".

What version of the product are you using? On what operating system?

Revision 4939d7bea8ba on Mac OS 10.7.3.

Please provide any additional information below.

Draft 6 of the R7RS says: "In a library declaration, it is an error ... to 
redefine or mutate an imported binding with define, define-syntax or set!." 
Here, I am mutating an exported binding, and I can find no prohibition of this.

Original issue reported on code.google.com by alan.wat...@gmail.com on 9 Mar 2012 at 6:54

GoogleCodeExporter commented 9 years ago
There is no prohibition, but it is not intended that mutations
necessarily be reflected in importing modules - I need to double
check the R7RS draft on this.

You need a level of indirection to share mutation across modules.
Typically this is done with a parameter object.

Original comment by alexsh...@gmail.com on 9 Mar 2012 at 7:03

GoogleCodeExporter commented 9 years ago
So how about changing this to an enhancement request? Give me an error if I 
attempt to mutate an exported binding (e.g., when I execute (set! bar "two\n")).

Original comment by alan.wat...@gmail.com on 9 Mar 2012 at 7:10

GoogleCodeExporter commented 9 years ago
I won't make this an error, but will try to provide
a warning (unless the WG votes to make reflecting the
mutation required, which is unlikely).

Original comment by alexsh...@gmail.com on 13 Mar 2012 at 2:29