[racket] What #lang to use to create teachpack?

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Mon Nov 4 18:54:31 EST 2013

On 11/4/13, 6:36 PM, Norman Ramsey wrote:
>   > I think you will find "#lang racket" the best language for writing
>   > teachpacks.
>
> Using "#lang racket" I have successfully create a package, installed
> it, and require'd it.  But when I print a structure defined in my
> package, the arguments don't print:
>
>     > (require geo)
>     > (length geonames)
>     10150
>     > (first geonames)
>     (make-usgs ...)
>     >
>
> I want my students to see the actual arguments rather than ..., as
> they would if I had used `define-struct` in ISL.  Is there a
> relatively easy way to achieve this?

Here are two options:

#lang racket
(provide geo (struct-out usgs))

(struct usgs (data) #:transparent #:constructor-name make-usgs)
(define geo
   (make-list 10150 (make-usgs "data!")))

;;

#lang racket
(provide geo (struct-out usgs))
(require (only-in lang/htdp-intermediate define-struct))

(define-struct usgs (data))
(define geo
   (make-list 10150 (make-usgs "data!")))

;;

The first uses transparent Racket structures.

The second uses ISL structures (which are probably really transparent 
Racket structures).

I don't think it makes much of difference which one you use.

David


Posted on the users mailing list.