On Oct 16, 10:02 am, Tom Lynch <[EMAIL PROTECTED]> wrote:
> Hi all, I have a naive question regarding Clojure macros. As someone
> new to Lisp-style macros, can I use the system to generate new names
> using substitution / token-pasting?
>
> Conceptually something like
>
> (defmacro paste-tokens [first second]
> `(def ~first~second []))
>
> so that (paste-tokens foo bar) expands to (def foobar []).
>
> I realise this may be a huge ideological no-no :-)
Why would it be? Code generation is a ideological yes-yes
in lisps.
user=> (defmacro paste-tokens [f s] `(def ~(symbol (str f s)) []))
nil
user=> (macroexpand-1 '(paste-tokens foo bar))
(def foobar [])
--
-asbjxrn
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---