I needed a macro if I wanted to avoid ' in calls. It may seem as nitpicking but (to-keyword name) is more readable and less error prone than (to-keyword 'name) if I need to use it in lots of places.
On Aug 24, 8:38 pm, Achim Passen <achim.pas...@gmail.com> wrote: > Hi! > > Am 24.08.2009 um 18:31 schrieb Dragan Djuric: > > > I needed (and created) a macro to generate keywords from symbols. I > > couldn't find anything ready, and I am still not completely > > comfortable with the solution I came up with. Any suggestions for > > improvement? > > If I understand you correctly, you'd like to convert symbols which > name vars to keywords qualified with the namespace which contains the > var's definition. You don't really need a macro for that, a regular > function will do. Here's a version using var metadata: > > (defn resolve-to-kw [sym] > (let [md (meta (resolve sym))] > (keyword (-> md :ns ns-name name) (-> md :name name)))) > > Hope this helps. > > Kind Regards, > Achim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---