[plt-scheme] PLAI mzscheme and drscheme question

From: Rohan Nicholls (rohan.nicholls at pareto.nl)
Date: Thu Apr 7 14:30:16 EDT 2005

At Wed, 6 Apr 2005 05:24:38 -0400,
Eli Barzilay wrote:
> 
> On Apr  6, Rohan Nicholls wrote:
> > [...]
> 
> Not a direct answer but...
> 
> The plai collection has combination of the datatype code with the HtDP
> language levels, which is not really used.  I suspect that some bad
> interaction between these things is what leads to this problem.  If
> you're just trying to make your way through the book, then you can try
> the code that I've hacked -- it's at
> 
>   http://www.ccs.neu.edu/course/csu660/resources.html
> 
> You get a "csu660.ss" to use as a language.  It is a little different
> than the plai language -- `define-type's are the same, but `type-case'
> should change like this:
> 
>   (type-case F1WAE expr
>     [num (n) n]
>     [add (l r) (+ (interp l fundefs) (interp r fundefs))]
>     ...)

Sorry I am being very slow with this but to clarify would that mean
that 
(define lookup 
  (lambda (name sc)
    (type-case SubCache sc
               [mtSub () (error 'lookup "no binding for identifier")]
               [aSub (bound-name bound-value rest-sc)
                     (if (symbol=? name bound-name)
                         bound-value
                         (lookup name rest-sc))])))

>   -->
>   (cases expr
>     [(num n) n]
>     [(add l r) (+ (interp l fundefs) (interp r fundefs))]
>     ...)

would become 
(define lookup 
  (lambda (name sc)
    (cases sc
          [mtSub () (error 'lookup "no binding for identifier")]
          [aSub (bound-name bound-value rest-sc)
                 (if (symbol=? name bound-name)
                     bound-value
                     (lookup name rest-sc))])))
?

> It should work fine in mzscheme or drscheme (the "CSU660 Class"
> language level).

(define-type FunDef
  [fundef (fun-name symbol?)
          (arg-name symbol?)
          (body F1WAE?)])

gives me this:
STDIN::768: define-type: cannot use the type name for a variant at:
fundef in: (define-type fundef (fundef (fun-name symbol?) (arg-name
symbol?) (body f1wae?)))

So if I name it to (define-type AFunDef .... this should work?
As I don't have to explicitly name the case I am referring to,
then there should be no problem because they are function calls
anyway, so each case needs to be unique within the namespace anyway?

Thanks for the help, 

Rohan

P.S. I wasn't sure whether to bug the whole list about this, so I
haven't copied them on this, if you feel someone besides myself might
be interested please do forward it.




Posted on the users mailing list.