David Nolen wrote:
> (defmacro foobar []
>   `'(+ a b))
>
> (let
>     [a 5
>      b 6]
>   (eval (foobar)))
>
>
>   

-You should almost never have to use eval.
-Don't use macros when a function will do

Thanks to the answer of chooser a bit earlier :

cara.trie> (defmacro foobar [] `(+ ~'a ~'b))
nil
cara.trie> (let [a 10 b 13] (foobar))
23

-Variable capturing macros can be bad style and dangerous too. You would 
usually pass the symbols to act upon as parameters.

cara.trie> (defmacro foobar [symb1 symb2] `(+ ~symb1 ~symb2))
nil
cara.trie> (let [a 10 b 13] (foobar a b))
23

Sacha

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to