How can I mix optional keyword arguments with the & rest stuff?
        Posted  
        
            by Rayne
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rayne
        
        
        
        Published on 2010-05-02T15:28:38Z
        Indexed on 
            2010/05/02
            15:37 UTC
        
        
        Read the original article
        Hit count: 261
        
I have a macro that takes a body:
(defmacro blah [& body] (dostuffwithbody))
But I'd like to add an optional keyword argument to it as well, so when called it could look like either of these:
(blah :specialthingy 0 body morebody lotsofbody)
(blah body morebody lotsofboy)
How can I do that? Note that I'm using Clojure 1.2, so I'm also using the new optional keyword argument destructuring stuff. I naively tried to do this:
(defmacro blah [& {specialthingy :specialthingy} & body])
But obviously that didn't work out well. How can I accomplish this or something similar?
© Stack Overflow or respective owner