Question

I'm trying to implement some of SICP graphic programs in Racket, but there are 2 problems:

When I need to use 'let' I can't use beginner language. When I try to change language, or open new file while using "advanced" language, I get this error:

module: identifier already imported from a different source

error when I try to load image module by (require 2htdp/image).

What's going on? Also, are there better ways to train with images in Scheme?

Was it helpful?

Solution 2

As Óscar mentions, you are better off with using #lang planet neil/sicp, However, if you want to import somethng that exports identical symbols you can prefix them:

(require (prefix-in hi: 2htdp/image))

Then all exported from that have prefix hi:, eg. (hi:circle 30 "outline" "red"). The colon isn't anything special. The prefix could have been xxx and it would be xxxcircle.

Also, you can only import the symbols you want:

; you only want circle and eclipse
(require (only-in 2htdp/image circle ellipse)) 

Or you can import everything except some symbols:

; everything except circle and ellipse
(require (except-in 2htdp/image circle)) 

And there is no reason not using racket or racket/base as language when you know this.

OTHER TIPS

It's not clear why you want to use 2htdp/image in the first place. A much more useful package to use would be Neil Van Dyke's SICP Support page, it provides a language with support for the book and includes the graphical language. That should be enough to solve both of your problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top