[racket] Any way to get "true" quasiquote behavior in match form?

From: Erik Silkensen (eriksilkensen at gmail.com)
Date: Sat Mar 10 00:25:52 EST 2012

I wonder if define-match-expander might be what you're looking for?  http://docs.racket-lang.org/reference/match.html?q=define-match-expander#(form._((lib._racket/match..rkt)._define-match-expander))

Erik

On Mar 9, 2012, at 8:22 PM, rob cook wrote:

> Thanks for the tips - I am new to using match, the answers are illuminating, and so close...
> 
> I perhaps oversimplified my example. What I actually need to do is to match on an arbitrary expression bound earlier., e.g.
> 
> (match foo
> (bar #t)
> (_ #f))
> 
> Where bar is bound to some valid *match* expression. It appears the ==  fits the bill for something that resolves to some literal value in the end. I need to match what might be a literal, but could be something like bar being  (list (and (? number?) (? odd?)))).
> 
> In other words, I'd like to be able to generate or have the user supply any arbitrary match expression, and use it for the bar in the match shown above. Ideas?
> 
> Thx again,
> Rob
> 
> On Fri, Mar 9, 2012 at 4:37 PM, rob cook <heycarnut at gmail.com> wrote:
> That is, without using a macro or eval. Id like to do:
> 
> (define a 4)
> (define l1 '(1 2 3))
> (match l1
>   (`(1 2 ,a) #t)
>   (_ #f))
> 
> So that this example would result in #f, and #t if a bound to 3.
> 
> Since of course match has its own quasiquote behavior, this does not seem possible w/o making a macro for "dynamic" match, or building the s-exp and using eval (yuck!).
> 
> Is this correct, or have I missed something obvious?
> 
> Thnx
> Rob
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120309/af62792a/attachment-0001.html>

Posted on the users mailing list.