One of my courses is using DrRacket for some sections of SICP. We're working on the metacircular evaluator and I have an R5RS code file (set-car!
and set-cdr!
) which I need to use with my work. Because the R5RS file is roughly 500 lines, I'd prefer to keep it in a separate buffer. How can I include it into my answer buffer's defintions? It appears racket/include
requires #lang racket
, but set-car!
and set-cdr!
are not in that language.
You can do the following:
Write the module in #lang r5rs, and add the following after the lang line:
(#%provide (all-defined))
Have your answer buffer also in #lang r5rs, and use #%require to pull in its definitions:
(#%require "some-module.ss")
For example, if I have an f1.ss with the following content:
#lang r5rs
(#%provide (all-defined))
(define (f x)
(* x x))
and an f2.ss with the following content:
#lang r5rs
(#%require "f1.ss")
(display (f 3))
(display (f 4))
then if I run f2.ss, it does the appropriate thing in displaying 916, and its Interactions buffer will know about all the definitions written in f1.ss.
This uses the Racket-specfic low-level module importing stuff mentioned in the documentation. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With