Dr Racket problems with SICP

10,841

Solution 1

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.)

Solution 2

I ran into problems trying to work thru the RSA example here (part of the SICP stuff):
http://mitpress.mit.edu/sicp/psets/ps3/readme.html

To get this working I had to do this:

1) Run thru the initial download by adding this to the top of a blank file:

#lang planet neil/sicp

and then hitting "Run"

2) Enjoy DrRacket's very user friendly, automatic download and install the PLaneT Neil module by going to grab a coffee ;-)

3) And then once it is installed, close DrRacket.

4) Reopen, and choose SICP PLaneT 1.15 from the Choose A Language list.
(I could not get adding the declaration at the top to work for me aside from doing that to perform the initial download.)

Good luck!

Solution 3

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

Share:
10,841
afkbowflexin
Author by

afkbowflexin

Updated on June 01, 2022

Comments

  • afkbowflexin
    afkbowflexin almost 2 years

    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.