The DrRacket REPL allows set!s on those variables that are assignable in the 
module and no others. That's by design. Roughly speaking, think of the 
Definitions window as a module and the REPL a way to perform computations as if 
we were a client of the module that can also use all of its internally defined 
functions, think super-client. But this super-client view does not enable you 
to mutate variables that weren't mutable in the first place .. just like a 
client can't do that either. 


On Oct 17, 2014, at 12:29 PM, Christian Wagenknecht <[email protected]> 
wrote:

> In the example as given below 'a' behaves like a constant whereas the value 
> named with 'x' can be modified (in the interaction window) as expected. Could 
> you help me please to understand what happened by (set! x "Bob")?
> 
> Definition window
> 
> #lang racket
> 
> (define a "Hello")
> 
> (define x "Hello")
> (set! x "Bob")
> 
> Interaction window
> 
> > (set! a 3)
> . . set!: assignment disallowed;
> cannot modify a constant
>  constant: a
> > (set! x 9)
> > x
> 9
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users


____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to