1
votes

Following the instructions in http://www.scheme.com/csug8/libraries.html, I could build a library smcho.ss.

(library (smcho simple (1))
    (export hello factorial)
    (import (rnrs (6)))

    (define (hello x)
      (+ x 10))

    (define (factorial n)
        (cond
            [(<= n 0) 1]
            [else (* n (factorial (- n 1)))]))
)

Then, install it with plt-r6rs --install smcho.ss (http://lists.racket-lang.org/users/archive/2009-September/035465.html).

However, when I tried to use it in top_level.ss,

(import (smcho simple) (rnrs (6)))    
(print (factorial 10))

I have error messages

scheme> plt-r6rs top_level.sc 
get-module-code: no such file: #<path:/Users/smcho/Desktop/scheme_lib/top_level.sc>
  context...:

What might be wrong? I checked that the ~/Library/Racket/6.3/collects directory stores correctly compiled library, so the issue should not be from the library.

1

1 Answers

0
votes

The issue was that I should have used (display (factorial 10)) not print. Furthermore, In DrRacket GUI, I needed to add #lang r6rs to run in it.

I'm not sure why display is OK when print or pr causes an issue.