Bobby C
Bobby C

Reputation: 2085

Cannot load File in Scheme, (using Simply Scheme Book and PLT Scheme)

I am using PLT Scheme (DrScheme). I want to load a file that I got from here. To load the file, I go into PLT Scheme and in the interactions window (or the bottom window), I type (load "simply.scm") and then press enter. It gives me this error:

simply.scm:20:12: set!: cannot mutate module-required identifier in: number->string

I have no clue how to fix that, please assist...

Extra Info: I am learning out of the book Simply Scheme Introducing Computer Science by Brian Harvey and Matthew Wright

Also, the link takes a little long to load, but it does work, i think they have the files on a really old server, so that may be why.

Upvotes: 3

Views: 2391

Answers (2)

nadeem
nadeem

Reputation: 721

Open DrScheme (or DrRacket as the newer version of the software is now called); from the Language menu select "Choose Language..." and make sure "Use the language declared in the source" is checked.

Then at the top of your file, put the following two header lines followed by whatever code you want from the book (I've chosen an example from the first chapter):

#lang racket
(require (planet dyoo/simply-scheme))

(define (pigl wd)
  (if (member? (first wd) 'aeiou)
      (word wd 'ay)
      (pigl (word (butfirst wd) (first wd)))))

Then click run. This should allow you to also type expressions in the Interactions pane to evaluate them.

Alternatively, you can replace the two lines above with one:

#lang planet dyoo/simply-scheme

But then the Simply Scheme language is not enabled in the Interactions pane.

You can find the documentation for this DrScheme/Racket simply-scheme library by clicking on the 'docs' link at the URL provided by Chris.

Upvotes: 10

C. K. Young
C. K. Young

Reputation: 223003

You should use the Racket Simply Scheme module. The file you have linked to is not compatible with Racket.

More specifically, in Racket, you're not allowed to use set! to overwrite existing function bindings, which is what that file does. (Technically, it can potentially break other Scheme implementations also, so this isn't a "Racket quirk" or anything.)

Upvotes: 7

Related Questions