<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Casey Klein wrote:<br><blockquote type="cite">I'd like to write a macro that accepts keyword arguments, e.g.,<br></blockquote><blockquote type="cite">(my-macro e1 #:kw e2 e3). syntax-case isn't much help in parsing the<br></blockquote><blockquote type="cite">macro's input. Do I need to do this parsing myself, checking for<br></blockquote><blockquote type="cite">duplicate/missing keywords, or is there some library solution I'm<br></blockquote><blockquote type="cite">missing?</blockquote><br></div>syntax-case does correctly match on keywords if you use them in your patterns.<div><br></div><div>For what it's worth, I have adopted an idiom I found in the definition of new define-struct:<div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">(define-syntax (my-form stx)</span><br><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp;(define (do-arguments args-stx)</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp;(syntax-case args-stx ()</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp;[() (do-final)]</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp;[(#:arg1 val other ...)</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp; (begin</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ; do something with the argument and its value</span></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></font><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">(do-arguments #'(other ...)))]))</span><br><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp;(define (do-final)</span></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp;; produce some final syntax<br></span></font><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp;)</span><br><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp;(syntax-case stx ()</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp;[(_ arg ...)</span><br><span class="Apple-style-span" style="font-family: Monaco; font-size: 12px; ">&nbsp;&nbsp; &nbsp; (do-arguments #'(arg ...)]))</span></blockquote><div><div><br></div><div>I typically store a bunch of state as internal defines and use it in do-final.</div><div><br></div><div>Something unrelated but potentially useful... I wrote a "human-friendly" macro version of keyword-apply that I'm going to add to the next version of Unlib.plt. Code is attached below.&nbsp;</div><div><br></div><div>Hope this helps,</div><div><br></div><div>-- Dave</div><div><br></div><div></div></div></div></body></html>