[plt-scheme] using plt-match.ss in teaching languages
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 3.99.0.23-svn1may2008 [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