On Fri, Dec 17, 2010 at 10:54 AM, Trevor <tcr1...@gmail.com> wrote: > n00b questions :) > > 1. How do I create a function and/or a macro that accepts an unbound > name and interprets that name as a symbol?
Function: (defn foo [x] (println x)) user=>(foo 'quux) quux nil user=> (defn bar [x] (do-something-with (symbol x))) user=> (bar "quux") ; whatever user=> (defmacro baz [x y] `(def x y)) user=> (baz quux 42) #'user/quux user=> quux 42 > this may seem silly or non-idiomatic, but really for specific > functions (and more likely macros) I don't want to have to protect the > name for it to be interpreted as a symbol. This is simply to > accommodate my personal, good or bad, behaviors. If you mean you don't want to have to quote it, well, macro arguments aren't evaluated during macro expansion so you can generally pass unquoted symbols to macros. In fact you do so whenever you use defn. With function arguments, you need to quote a symbol to pass a symbol, or else pass a string the function will convert by using (symbol x) on it. > 2. Is there a form for anonymous macros? Nope. I'm not sure why you'd want one, either. -- 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