<div dir="ltr">Thanks, that's perfect! I knew it couldn't have been overlooked :)</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Apr 7, 2013 at 5:31 PM, J. Ian Johnson <span dir="ltr"><<a href="mailto:ianj@ccs.neu.edu" target="_blank">ianj@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The ~in-between pattern and its specializations ~once and ~optional are great for this purpose. Anything matching this pattern must appear in the range given in ~in-between, even in ellipsis'd contexts.<br>
(a:id b:id (~or (~once (~seq #:key1 c:id)) (~once (~seq #:key2 d:id))) ...)<br>
<br>
-Ian<br>
<div><div class="h5"><br>
----- Original Message -----<br>
From: "Scott Klarenbach" <<a href="mailto:scott@pointyhat.ca">scott@pointyhat.ca</a>><br>
To: "Racket mailing list" <<a href="mailto:users@racket-lang.org">users@racket-lang.org</a>><br>
Sent: Sunday, April 7, 2013 8:23:29 PM GMT -05:00 US/Canada Eastern<br>
Subject: [racket] Using syntax/parse, how to accept keyword arguments in any order yet not allow duplicates?<br>
<br>
<br>
<br>
Hi there,<br>
<br>
<br>
I'd like to create a macro that accepts non-optional keyword arguments in any order. It should however, ensure that all the arguments are provided. Finally, it should not allow duplicates.<br>
<br>
<br>
So far I've only been able to solve for my first criteria.<br>
<br>
<br>
As a test, I have this:<br>
<br>
<br>
<br>
(syntax-parse stx<br>
[(a:id b:id (~or (~seq #:key1 c:id) (~seq #:key2 d:id)) ...) #t])<br>
<br>
<br>
Now, that matches for:<br>
#'(a b #:key1 hey #:key2 there)<br>
#'(a b #:key2 there #:key1 hey)<br>
<br>
<br>
<br>
Which is what I want. But unfortunately it also matches:<br>
#'(a b #:key2 there)<br>
<br>
<br>
And worse:<br>
#'(a b #:key2 one #:key2 two #:key2 three)<br>
<br>
<br>
The reasons are obvious. I'm just wondering if there's a more robust way of dealing with these types of scenarios that I'm missing? I thought of combining an (~or (~and clause but that becomes very tedious, and leaves the duplicate problem unsolved.<br>
<br>
<br>
Thanks.<br>
<br>
--<br>
Talk to you soon,<br>
<br>
Scott Klarenbach<br>
<br>
PointyHat Software Corp.<br>
<a href="http://www.pointyhat.ca" target="_blank">www.pointyhat.ca</a><br>
p <a href="tel:604-568-4280" value="+16045684280">604-568-4280</a><br>
e <a href="mailto:scott@pointyhat.ca">scott@pointyhat.ca</a><br>
200-1575 W. Georgia<br>
Vancouver, BC V6G2V3<br>
<br>
_______________________________________<br>
To iterate is human; to recur, divine<br>
</div></div>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Talk to you soon,<br><br>Scott Klarenbach<br><br>PointyHat Software Corp.<br><a href="http://www.pointyhat.ca" target="_blank">www.pointyhat.ca</a><br>p 604-568-4280<br>
e <a href="mailto:scott@pointyhat.ca" target="_blank">scott@pointyhat.ca</a><br><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">200-1575 W. Georgia</span><br>
Vancouver, BC <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">V6G2V3</span><br><br>_______________________________________<br>To iterate is human; to recur, divine
</div>