[racket] Separate files in the HtDP languages?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Nov 16 20:39:27 EST 2013

At Sat, 16 Nov 2013 12:44:03 -0500, Norman Ramsey wrote:
> On their next assignment, my students will reuse code they have
> built for binary search trees.  I would prefer that they place the
> old code in a different source file than the new code.  I tried
> doing this using "require", but I cannot figure out how to get
> "require" to load a file that is written in Intermediate Student Language.
> Is there another mechanism I should try?  Is the thing I want to do
> even possible?

You can `require` a module that is implemented in ISL, but ISL doesn't
include `provide`, so you normally don't get anything from the module.

(It might be better if ISL implicitly exported all definitions. I
forget whether we've considered that change before.)

Since ISL includes `require`, you can use it to get `provide`. For
example, if "p.rkt" has

 #lang racket
 (provide provide)

then "a.rkt" in ISL could be

 (require "p.rkt")

 (define (sum a b)
   (+ a b))

 (provide sum)

and then "b.rkt" in ISL can be

 (require "a.rkt")

 (sum 1 2)


Posted on the users mailing list.