[plt-scheme] Interactions in the Module language

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Tue Jan 20 10:25:25 EST 2009

We covered mutation today in lecture. I had not done this before using 
the Module language. Afterwards, a student came up and showed me this 
interesting phenomenon.

In the Definitions window:

#lang scheme

(define a 1)
(set! a 2)
(define b 1)

In the Interactions window:

 > (set! a 3)
 > a
 > (set! b 2)
set!: cannot modify a constant: b

Now, I know the top level is hopeless, and I have an intuitive 
explanation, which is that in the analysis of the module in the 
Definitions window, b has been optimized down to a constant but a has 
not. Is there a more accurate explanation, and does a prediction of this 
exist in Help Desk? I note the parameter 
`compile-enforce-module-constants', whose explanation seems to have some 
bearing, but the parameter seems to have value #f in the Interactions 
window, and I cannot get it to do anything useful in this example. 
Thanks. --PR

Posted on the users mailing list.