[plt-scheme] using plt-match.ss in teaching languages

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Sun May 4 13:16:24 EDT 2008

Matthias Felleisen wrote:
> If you change it to this:
> (require (lib "plt-match.ss" "mzlib"))
> (define-struct myposn (x y))
> (define (dist p1 p2)
>   (match (list p1 p2)
>     [(list (struct myposn (x1 y1)) (struct myposn (x2 y2)))
>      (sqrt (+ (sqr (- x1 x2)) (sqr (- y1 y2))))]))
> (dist (make-myposn 0 0) (make-myposn 3 4))
> it works in all levels in my svn (version [3m].) I 
> think you're seeing a bug in match that was recently fixed.

Quasipatterns don't appear to work (I'm using the version cited above).

(match '(1 (2 3)) [`(1 (,x 3)) x])

produces 2 when preceded by #lang scheme and run in Module, but when 
preceded by

(require (lib "plt-match.ss" "mzlib"))

and run in Advanced Student, it says:

x: name is not defined, not a parameter, and not a primitive name

highlighting the last occurrence of x in the expression.

(match '(1 (2 3)) [(list 1 (list x 3)) x]) works.

I suppose I can live with that, but it would be nice to explain to the 
students why the former failed, and what else won't work. Thanks for any 
enlightenment anyone can provide. --PR

Posted on the users mailing list.