<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Untested but I think this will work<br>
<br>
(define-syntax (my-macro stx)<br>
(syntax-case stx ()<br>
[(_ (id1 id2 ...) body ...)<br>
#'(lambda (expr)<br>
(match expr [(list 'id1 id2 ...) body ...]))]))<br>
<br>
On 01/15/2013 10:22 PM, Paul Meier wrote:<br>
</div>
<blockquote
cite="mid:CA+VTZ0aAj2xw5HT0UO18_n108nSUas5T8wKOuXZauTNMD30sGA@mail.gmail.com"
type="cite">
<div dir="ltr">Hi friends,
<div><br>
</div>
<div style="">I'm working on a macro that expands into a match
statement. It looks something like</div>
<div style=""><br>
</div>
<div style="">(define-syntax (my-macro stx)</div>
<div style="">
(syntax-case stx ()</div>
<div style=""> [(_ (id1 id2 ...) body ...)</div>
<div style=""> (with-syntax ([match-pattern </div>
<div style=""> (datum->syntax stx
(cons 'list (syntax->datum #'(id1 id2 ...))))])</div>
<div style=""> #'(lambda (expr)</div>
<div style=""> (match expr</div>
<div style=""> [match-pattern body ...])))))</div>
<div style=""><br>
</div>
<div style="">So in effect, it expands</div>
<div style=""><br>
</div>
<div style="">
(my-macro (push i) (printf "~v" i)</div>
<div style=""><br>
</div>
<div style="">into</div>
<div style=""><br>
</div>
<div style="">(lambda (expr)</div>
<div style=""> (match expr</div>
<div style=""> [(list push i) (printf "~v" i)]))</div>
<div style=""><br>
</div>
<div style="">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 style=""><br>
</div>
<div style="">((my-macro (push i) i) '(dont-push 45)) will
evaluate to 45, rather than fail to match (the desired
behavior).</div>
<div style=""><br>
</div>
<div style="">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 style=""><br>
</div>
<div style="">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 style=""><br>
Any help would be appreciated. Thanks for your time; I'm
loving my explorations into Racket ^_^</div>
<div style=""><br>
</div>
<div style="">-Paul</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">____________________
Racket Users list:
<a class="moz-txt-link-freetext" href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a>
</pre>
</blockquote>
<br>
</body>
</html>