I am going through SICP as a self-study and am on the picture language section in Chapter 2. I have been using DrRacket for the earlier exercises, but I get compilation errors when trying to do an exercise based on the 'draw-line' picture function in this section of the book.
Specifically, this code ...
(define (segments->painter segment-list)
(lambda (frame)
(for-each
(lambda (segment)
(draw-line
((frame-coord-map frame) (start-segment segment))
((frame-coord-map frame) (end-segment segment))))
segment-list)))
...produces this error ...
draw-line: unbound identifier in module in: draw-line
So I did a bit of research on this forum and installed the SICP package that Neil Van Dyke offers (http://www.neilvandyke.org/racket-sicp/#(part._usage)). I followed all of the steps, changed the language to SICP as directed, but still get the same error.
I assumed that the purpose of this package was to have defined this 'built-in' function (as well as others in the book). Just to anticipate some questions, I do not have 'require' statements in the file and used '#lang planet neil/sicp' to specify the language instead of using the menu (I also tried changing the language to SICP using the menu and get an even stranger error; see the postscript below). My environment is Windows 7 and the version of DrRacket is 5.3.1.
Perhaps I am just making a rookie mistake; any insight would be appreciated.
Thanks.
PS: For those interested, when I set the language to 'SICP (PLaneT 1.17)' using the menu, I get the following error for any definition that I try to compile (even the most trivial)...
<unsaved editor>:1:0: #%top-interaction: unbound identifier;
also, no #%app syntax transformer is bound in: #%top-interaction
draw-line
. That being said, this omission appears to be by design, because it's not used anyone except for insegments->painter
, andsegments->painter
is already given to you as part of the library. Other people have shown you how to write adraw-line
from scratch using DrRacket's primitive drawing libraries, but you don't need to use it directly anyway for SICP's picture language exercises. – dyoosegments->painter
. You can see how it's being done in DrRacket: planet.racket-lang.org/package-source/soegaard/sicp.plt/2/1/…. So there is a definition fordraw-line
in there (actually, in there it's calleddraw-line-on-screen
), but you are not supposed to use it as a user of the picture language. – dyoo