[racket] Using syntax/parse, how to accept keyword arguments in any order yet not allow duplicates?

From: Scott Klarenbach (scott at pointyhat.ca)
Date: Sun Apr 7 20:23:29 EDT 2013

Hi there,

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.

So far I've only been able to solve for my first criteria.

As a test, I have this:

(syntax-parse stx
  [(a:id b:id (~or (~seq #:key1 c:id) (~seq #:key2 d:id)) ...) #t])

Now, that matches for:
#'(a b #:key1 hey #:key2 there)
#'(a b #:key2 there #:key1 hey)

Which is what I want.  But unfortunately it also matches:
#'(a b #:key2 there)

And worse:
#'(a b #:key2 one #:key2 two #:key2 three)

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.

Thanks.

-- 
Talk to you soon,

Scott Klarenbach

PointyHat Software Corp.
www.pointyhat.ca
p 604-568-4280
e scott at pointyhat.ca
200-1575 W. Georgia
Vancouver, BC V6G2V3

_______________________________________
To iterate is human; to recur, divine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130407/aba7d17e/attachment.html>

Posted on the users mailing list.