[racket-dev] racket/match is broken

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Oct 6 14:22:11 EDT 2011

Just now, Robby Findler wrote:
> 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.

OK, "... while matching a particular pattern".

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!



Posted on the dev mailing list.