> I have a function that relies on a keyword being supplied. The keyword
> is used to find something in a static map. I want to put in the doc-
> string:
> (str "blah blah blah, arg1 must be one of " (keys map))
> Suggestions?


You'd need to generate a suitable function definition using a macro.

E.g.,

(defmacro def-my-map-fun [name m]
   `(defn ~name
      ~(str "arg1 must be one of " (keys m))
      [~'arg1]
      (println ~'arg1 ~m)))


user=> (def-my-map-fun foobar {:foo :bar})
#'user/foobar

user=> (doc foobar)
-------------------------
user/foobar
([arg1])
   arg1 must be one of (:foo)
nil

user=> (foobar 5)
5 {:foo :bar}
nil



Now's the moment when someone shows a better way ;)

-R

--~--~---------~--~----~------------~-------~--~----~
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