TheReasonedSchemer2ndEd / CodeFromTheReasonedSchemer2ndEd

Code from Chapter 10 & Appendix A, implementation, and Chapters 7 & 8, arithmetic
https://mitpress.mit.edu/books/reasoned-schemer-second-edition
MIT License
130 stars 22 forks source link

DrRacket and trs2-impl.scm #1

Open elfi opened 5 years ago

elfi commented 5 years ago

Hi,

I'm starting to read the book and would like to play with examples along - using DrRacket. However,

#lang Racket   (or R5RS)
(load "/tmp/CodeFromTheReasonedSchemer2ndEd/trs2-impl.scm")

leads to an error:

/tmp/CodeFromTheReasonedSchemer2ndEd/trs2-impl.scm:20:0: #%top-interaction: unbound identifier;
 also, no #%app syntax transformer is bound in: #%top-interaction

How can I use trs2-impl.scm implementation in DrRacket?

Thank you!

hayesall commented 4 years ago

Here is a fix:

Modify trs2-impl.scm to declare a language and provide functions/macros:

; file trs2-impl.rkt

#lang racket

(provide run
     run*
     var?
         ==
         conj
         disj
         succeed
         fail
         fresh
         conde
         conda
         condu
     )

In DrRacket, use require:

#lang racket

; This assumes `trs2-impl.scm` is in your home directory, modify as needed.
(require "trs2-impl.scm")

(run* q
      (disj
       (== q 5)
       (== q 6)))
elfi commented 4 years ago

Yes, this solves the problem. Thank you!