views:

303

answers:

2

I'm working through SICP. Currently, in the first chapter, I'm having problems getting Racket to let me redefine "primitives". For instance, I was under the impression that I should be able to arbitrarily do "(define + 5)" and that would be fine or redefine the sqrt procedure. Instead, I get this: "define-values: cannot change constant variable: +" I have the language currently set to R5RS, which I was under the impression would take care of the compatibility issues with SICP.

+3  A: 

In the language panel, you need to disable "disallow redefinition of initial bindings." This fixes the issue.

Josh
+7  A: 

Even if possible, such redefinitions are not something that you should do without really understanding how the system will react to this. For example, if you redefine +, will any other code break? The answer to that in Racket's case is "no" -- but this is because you don't really get to redefine +: instead, you define a new +, which only your code can use.

As for the language choice -- Rackets R5RS mode is a very strict one, and it's not something that you'd usually want to use. For a much more SICP-friendly environment, see Neil Van Dyke's SICP Support page which will provide you with a language specifically made for the book. (IIRC, it even has the graphical language that the books shows off.)

Eli Barzilay
I actually ended up going ahead and installing Neil Van Dyke's package, so that I could have support for the picture language and for streams. Initially, I was just irritated that I couldn't work through some of the examples in the book. Thanks!
Josh