Re: how to understand macro in clojure?

2009-09-29 Thread John Harrop
On Mon, Sep 28, 2009 at 5:23 AM, Jarkko Oranen chous...@gmail.com wrote: What happens is, when you call (mfloat + 1 2) the macro evaluates ('+ (float 1) (float 2)), ie. it calls the *symbol* + with parameters 1.0 and 2.0. Symbols, when used as functions, look themselves up in whatever

Re: how to understand macro in clojure?

2009-09-28 Thread Michael Wood
Hi 2009/9/26 gerryx...@gmail.com gerryx...@gmail.com: (defn float2 [f a b]  (f (float a ) (float b))) (float2 + 1 2) = 3.0 (defmacro mfloat2 [f a b]  (f (float a) (float b))) (mfloat2 + 1 2 ) = 2.0  ???   macro expend to last expression in list,right? This is because (mfloat2 + 1 2)

Re: how to understand macro in clojure?

2009-09-28 Thread Jarkko Oranen
On Sep 28, 12:13 pm, Michael Wood esiot...@gmail.com wrote: Hi 2009/9/26 gerryx...@gmail.com gerryx...@gmail.com: (defn float2 [f a b]  (f (float a ) (float b))) (float2 + 1 2) = 3.0 (defmacro mfloat2 [f a b]  (f (float a) (float b))) (mfloat2 + 1 2 ) = 2.0  ???   macro

how to understand macro in clojure?

2009-09-25 Thread gerryx...@gmail.com
(defn float2 [f a b] (f (float a ) (float b))) (float2 + 1 2) = 3.0 (defmacro mfloat2 [f a b] (f (float a) (float b))) (mfloat2 + 1 2 ) = 2.0 ??? macro expend to last expression in list,right? (defmacro m2float2 [f a b] `(~f (float ~a) (float ~b))) (mfloat2 + 1 2) = 3.0 (defmacro