[racket-dev] racket/match is broken

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Oct 6 14:20:55 EDT 2011

On Thu, Oct 6, 2011 at 1:12 PM, Eli Barzilay <eli at barzilay.org> wrote:
> A few minutes ago, Prabhakar Ragde wrote:
>> Sam wrote:
>> > Unlike, say, `syntax-parse', `match' isn't designed for the
>> > use-case of building ASTs while matching.
>> Wait, what? That's exactly what I want to use it for when writing
>> toy interpreters for pedagogical purposes. Or am I misunderstanding
>> what you're saying here? I want to do PLAI-style things, but with
>> `match' instead of `type-case'. --PR
> Sam is talking about building the ASTs *while* matching, which is what
> Jay was trying to do with uses of `app'.  I think that a teaching
> context is in particular one where such a thing doesn't fit -- it
> obscures the distinction between the side the sexpr goes into, and the
> side where an AST comes out.

It seems difficult to argue that this:

(struct plus (left right))
(define (parse sexp)
  (match sexp
    [`(+ ,lhs ,rhs) (plus (parse lhs) (parse rhs))]
    [(? number?) sexp]))

is not build ing the ast "while matching".

Nevertheless, this is not what Sam was talking about.


Posted on the dev mailing list.