On Aug 25, 1:47 pm, Dragan Djuric <[email protected]> wrote:
> 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.
If that's all you do, then the easiest approach is to write both the
function and the macro.
Assume you have the function version, called to-keyword* ("foo*" is a
naming convention for something that is a "variant of foo"), then the
macro is as easy as:
(defmacro to-keyword [sym]
`(to-keyword* ~sym))
the driver function idiom is very common and useful, as writing
functions is much less error prone than writing macros. This approach
also has the advantage that if you ever need to transform a collection
of symbols, all you need to do is map the to-keyword* function.
--
Jarkko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
-~----------~----~----~----~------~----~------~--~---