> On Sat, Dec 19, 2009 at 3:58 PM, Stuart Halloway
> <stuart.hallo...@gmail.com> wrote:
>> In Clojure it is idiomatic to have optional args at the front of the
>> signature. This makes it easy to define convenient caller APIs, but  
>> it
>> leads to bulky let forms like this one (from clojure.core/defmulti)

There's clojure.contrib.def/name-with-attributes for the frequent case  
of a def-ing macro that takes an optional docstring and/or attribute  
map:

(defn name-with-attributes
   "To be used in macro definitions.
    Handles optional docstrings and attribute maps for a name to be  
defined
    in a list of macro arguments. If the first macro argument is a  
string,
    it is added as a docstring to name and removed from the macro  
argument
    list. If afterwards the first macro argument is a map, its entries  
are
    added to the name's metadata map and the map is removed from the
    macro argument list. The return value is a vector containing the  
name
    with its extended metadata map and the list of unprocessed macro
    arguments."
   [name macro-args]
...)

Konrad.


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to