On Nov 23, 12:37 pm, "Ralf Bensmann" <[EMAIL PROTECTED]> wrote: > Hi all, > > how can I create a var with a "dynamic name for a symbol" using the def > special form?
This works: user=> (defmacro defsym [symbol & body] `(def ~(eval symbol) [EMAIL PROTECTED])) nil user=> (defsym (symbol "user" "bar") 42) #'user/bar user=> bar 42 But only if the namespace already exists: user=> (defsym (symbol "foo" "bar") 42) java.lang.Exception: Can't refer to qualified var that doesn't exist (NO_SOURCE_FILE:11) In general, you probably don't want to do this, anyway. As an alternative, try using a map. -Stuart Sierra --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---