[plt-scheme] Algebraic patterns

From: Robert Bruce Findler (robby at cs.uchicago.edu)
Date: Tue Oct 1 12:32:15 EDT 2002

Wow, this looks great!

One thought: most of those forms add syntax to places that were illegal
already; eg (let ([(list x y) (list 1 2)]) x) was illegal before and so
it seems good to change it in that way. The one that doesn't do that is
define. In your world, this:

  (define (id x) x)

would probably be an error instead of defining the identity function.
So, I wonder if it would be better to only stick with adding meaning to
things that were illegal before and support patterns like this:

  (define (id--on-pairs (cons x y)) (cons x y))

but not patterns like this:

  (define (cons hd tl) (cons 1 2))

You might have with a new define-pattern form for the above, tho.

One other thought: you could also add support for curried function

  (define ((adder x) y) (+ x y))
  (define add3 (adder 3))


Posted on the users mailing list.