ds# inside the def is inside a ~() which means it's expected to exist outside of the ` like: (defmacro ... (let [ds# "something] `(def ~(... ds# ) .... ))
maybe try the let block be outside of the ` ? but that means you probably need to use eval It's funny I tried the same thing like you like 1 day ago here: https://github.com/DeMLinkS/demlinks/commit/85219208007fff6e7a11fb579d7125c73a6dc597 by trying to put the let inside the ` but failed On Sun, Feb 24, 2013 at 6:02 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote: > 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/**group/clojure?hl=en<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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > . > For more options, visit > https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . > > > -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- 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.