Hi everyone,

I cannot figure out for the life of me how to pass in an optional doc-string into a 'defsomething' macro and have it to work. If I hard-code it then it works just fine...

(defmacro def-plus-doc [name & syms]
`(def ~(with-meta name (assoc (meta name) :doc "HI!")) ~@syms)) ;;this will work just fine

(defmacro def-plus-doc [name & syms] ;;slightly augmented to detect doc-string
`(let [[doc# & syms# :as all#] (vector ~@syms)
        cs#  (if (string? doc#) [syms# true] [all# false])
ds# (if (second cs#) doc# "This workflow has not been documented...")]
   (def ~(with-meta name (assoc (meta name) :doc ds#)) ~@syms)))

;;fails with CompilerException java.lang.RuntimeException: Unable to resolve symbol: ds# in this context, compiling:(NO_SOURCE_PATH:5:26)

why is it so hard? I've been trying for almost 3 hours!!!! nothing seems to work... :(

Jim


--
--
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
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to