Maybe you could have something like (in-match ...) ?

On Fri, Nov 23, 2018 at 4:54 PM Alexis King <lexi.lam...@gmail.com> wrote:

> The trouble, sadly, is that this grammar is ambiguous. In
>
>   (for ([(x y) s])
>     ....)
>
> should (x y) be parsed as a single match pattern or as two binders for a
> two-valued sequence (such as one produced by in-hash, for example)? You
> could make it unambiguous in various ways, such as by requiring uses of
> match patterns to all use the multi-valued binder syntax (with an extra set
> of parens), but that’s a bit clumsy. Unfortunately, I can’t think of any
> particularly elegant way to support match patterns in for loop binders in a
> backwards-compatible way.
>
> Alexis
>
> > On Nov 22, 2018, at 20:14, Greg Hendershott <greghendersh...@gmail.com>
> wrote:
> >
> >> (define-syntax (match-for stx)
> >
> > That's nice.
> >
> > Sometimes I wish I could do the general thing -- use `match` patterns
> > in the binding clauses for any `for`-family form.
> >
> > I often do something like this:
> >
> >    (define xs (list (cons 1 2) (cons 3 4)))
> >
> >    (for ([x (in-list xs)])
> >      (match-define (cons a b) x)
> >      (use a b))
> >
> > Instead it would be nice to write:
> >
> >    (for ([(match-define (cons a b)) (in-list xs)])
> >      (use a b))
> >
> > Or even just:
> >
> >    (for ([(cons a b c) (in-list xs)])
> >      (use a b))
> >
> > In the grammar, `id` becomes `id-or-match-pattern`.
> >
> > On the other hand, this would only really help in simple
> > `match-define` destructuring -- as opposed to using `match` to handle
> > variations in the data. And although I do the former a lot, I do the
> > latter even more.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to