<div dir="ltr">And that did it! Thanks so much ^_^<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 15, 2013 at 9:27 PM, Jon Rafkind <span dir="ltr"><<a href="mailto:rafkind@cs.utah.edu" target="_blank">rafkind@cs.utah.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Untested but I think this will work<div class="im"><br>
<br>
(define-syntax (my-macro stx)<br>
(syntax-case stx ()<br>
[(_ (id1 id2 ...) body ...)<br></div>
#'(lambda (expr)<br>
(match expr [(list 'id1 id2 ...) body ...]))]))<div><div class="h5"><br>
<br>
On 01/15/2013 10:22 PM, Paul Meier wrote:<br>
</div></div></div>
<blockquote type="cite"><div><div class="h5">
<div dir="ltr">Hi friends,
<div><br>
</div>
<div>I'm working on a macro that expands into a match
statement. It looks something like</div>
<div><br>
</div>
<div>(define-syntax (my-macro stx)</div>
<div>
(syntax-case stx ()</div>
<div> [(_ (id1 id2 ...) body ...)</div>
<div> (with-syntax ([match-pattern </div>
<div> (datum->syntax stx
(cons 'list (syntax->datum #'(id1 id2 ...))))])</div>
<div> #'(lambda (expr)</div>
<div> (match expr</div>
<div> [match-pattern body ...])))))</div>
<div><br>
</div>
<div>So in effect, it expands</div>
<div><br>
</div>
<div>
(my-macro (push i) (printf "~v" i)</div>
<div><br>
</div>
<div>into</div>
<div><br>
</div>
<div>(lambda (expr)</div>
<div> (match expr</div>
<div> [(list push i) (printf "~v" i)]))</div>
<div><br>
</div>
<div>Here is the problem: I'd like the first entry of
the match list to be quoted (e.g. 'push) rather than unquoted,
as it is above, since 'match' will interpret this as a free
variable, meaning</div>
<div><br>
</div>
<div>((my-macro (push i) i) '(dont-push 45)) will
evaluate to 45, rather than fail to match (the desired
behavior).</div>
<div><br>
</div>
<div>Unfortunately, trusty (quote (syntax->datum stx
id1)) and or any variation thereof will do what it's supposed
to: quote whatever expression will evaluate into whatever I
want quoted.</div>
<div><br>
</div>
<div>I could just write the quotes into the expressions
using the macro, a la (my-macro ('push i) ...), but Shirly
there's a way around this?</div>
<div><br>
Any help would be appreciated. Thanks for your time; I'm
loving my explorations into Racket ^_^</div>
<div><br>
</div>
<div>-Paul</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>____________________
Racket Users list:
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a>
</pre>
</blockquote>
<br>
</div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>