[plt-scheme] exporting mutable identifiers

From: Michele Simionato (michele.simionato at gmail.com)
Date: Sat May 2 00:24:02 EDT 2009

The R6RS (section 7.2) says that
All explicitly exported variables are immutable in both the exporting
and importing libraries. It is thus a syntax violation if an
explicitly exported variable appears on the left-hand side of a set!
expression, either in the exporting or importing libraries.

I tried this program

(library (experimental mod1)
  (export x incr-x)
  (import (rnrs))

  (define x 0)
  (define (incr-x)
    (set! x (+ 1 x))

on Ikarus, Ypsilon and Larceny and indeed it fails with a "attempted
to mutate an immutable variable" error. However plt-r6rs does not give
any warning and compiles the library just fine, at
least in PLT 4.0. Maybe this has been fixed in later versions but I
wanted to report it,
just to ask what it is the situation now.

    Michele Simionato

Posted on the users mailing list.