[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Scheme-reports] Identifiers imported "by reference or value"?


R7RS defines a variable to be an identifier bound to a location.

Such a (global) variable could be introduced in a library by (define x 12), so x is bound to a location, in which the value 12 is stored.

Exporting this variable and importing it into the top-level program means by 5.2. of the report (as I understand it) that the identifier (that is the naming of the location) is (up to renaming) visible in the top-level program. To make the following reasoning easier, let us suppose that the identifier imported to the top-level program is renamed to y.

What is supposed to happen if in the running program a call into the library performs (set! x 13)? I think it is intended that accessing y in the top-level program still yields 12 (at least this is, what chibi-scheme does, with which I am experimenting), and which would allow a number of optimizations at compile-time. [If I understand correctly, it is only forbidden to mutate an imported binding, not an exported one.]

However, if I read the report as it is written, (set! x 13) stores the value 13 in the location to which x is bound; but this is the same location that is visible in the top-level program, so accessing y should yield 13?

(In 4.1.4. Procedures, it says explicitely that the arguments of a call are stored in fresh locations, so for calls everything is clear.)


Scheme-reports mailing list