[plt-scheme] htdp and modules

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Nov 22 09:16:10 EST 2007

You can use the module language and restrict the internal of a module  
to Beginning Student (and friends) as follows:

(module foo (lib "htdp-beginner.ss" "lang")
   (require (lib "testing.ss" "htdp"))
   (require (lib "world.ss" "htdp"))

   (define-struct world (x))
   ;; World = (make-world Nat)

   ;; data example:
   (define world0 (make-world 10))

   ;; World -> Scene
   (define (world-image w)
     (place-image (circle 3 'solid 'red) (world-x w) 50 BACK))

   ;; Scene
   (define BACK (empty-scene 100 100))

   (check-expect (world-image world0)
                 (place-image (circle 3 'solid 'red) 10 50 BACK))
   (generate-report))

As of 37x, the teaching languages understand a limited form of  
require. (This is part of gearing up for HtDP/2e.)

At the prompt, you get the familiar constructor syntax:

Welcome to DrScheme, version 371.3-svn12nov2007 [3m].
Language: (module ...); memory limit: 128 megabytes.
 > world0
#(struct:world 10)
 >

May I ask why you are not using HtDP this term? -- Matthias


On Nov 22, 2007, at 6:01 AM, Jan Christiansen wrote:

> Hi,
>
> we use drscheme in a practical course to teach programming in the  
> first term. In previous terms we used the "how to design programs"  
> languages.
>
> Now we would like to use modules. Is it correct that the "how to  
> design programs" languages do not support modules? How can I use  
> modules and support the students with the features they are used  
> to? It would be okay if I can tell the students which modules they  
> have to import. Right now I have discovered that I get the hdtp  
> list functions by importing list.ss and the local define construct  
> by importing etc.ss. What I am especially missing is a printer for  
> arbitrary data structures defined by the define-struct command. For  
> example with htdp I get
>
> > (make-tuple 1 2)
> (make-tuple 1 2)
>
> while in other languages I get
>
> > (make-tuple 1 2)
> #<struct:tuple>
>
> Regards, Jan
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.