[racket] Separate files in the HtDP languages?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Nov 17 12:36:56 EST 2013


This question comes up over and over again so I should write down 
my ideas in a little HtD essay. 

Part of the HtDP philosophy is that I want students to ask for 
concepts. For example, once you have written the same list template
over and over again, you want them to say "isn't there a way to 
avoid writing this same schema repeatedly? and you're ready with 
"I am glad you asked, here are loops defined in ISL and they are
what you want." In the same spirit, I want them to ask for modules
and components. 

HtDC (as in component not classes) starts with module, require, 
and provide. But provide is provide with contracts so that students
get protection against errors. That is, when things go wrong they 
have an idea in which file to look for errors. This much has been 
written for a couple of years but I can't find the time to push ahead. 

The request for provide has been an open bug report for years. I have
closed old ones and let new ones sit. 

;; --- 

If you wish to break this barrier, see Matthew's standard work-around. 

;; --- 

My personal preference is to (1) not have code from one assignment
be critical for the next one and (2) have single files for solutions. 
The former helps with the latter. The former is important for weaker
students. In my own courses, I switch partners between assignments
for which you may need to repair (not include) code from previous 
assignments. 

-- Matthias









On Nov 16, 2013, at 8:39 PM, Matthew Flatt wrote:

> 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)
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users


Posted on the users mailing list.