Re: Using macro to generate part of fn

2010-09-19 Thread Konrad Hinsen
On 19 Sep 2010, at 07:21, Stuart Campbell wrote: In this method, the first two parameters may be null. So, my fn looks like this: (defn exported-keys ([table] (exported-keys nil table)) ([schema table] (exported-keys nil schema table)) ([catalog schema table] (fetch-metad

Re: Using macro to generate part of fn

2010-09-18 Thread Stuart Campbell
> > Macroexpansion is part of the expression evaluation mechanism. In your > example > > >(defn foo > ([bar] (foo bar :default)) > (special-fn-spec)) > > the whole defn-form is macroexpanded first, yielding something like > >(def foo (fn ([bar] (foo bar :default))

Re: Using macro to generate part of fn

2010-09-18 Thread Konrad Hinsen
On 18 Sep 2010, at 07:15, Stuart Campbell wrote: In the following contrived example, I get an error when macroexpanding (defn foo ...): (defmacro special-fn-spec [] '([bar baz] (println bar baz))) (defn foo ([bar] (foo bar :default)) (special-fn-spec)) The error is: Parameter declarat

Re: Using macro to generate part of fn

2010-09-18 Thread Nicolas Oury
in a (def f [] E), only a E is going to be macro-expanded. (I think the rule of thumb is that macro are only expanded in a position where an expression is.) You can build : (defmacro macro-expanding-defn [name l] ) using a combination of macro-expand, defn and macro? (You can also do a simpler

Using macro to generate part of fn

2010-09-17 Thread Stuart Campbell
Hello, In the following contrived example, I get an error when macroexpanding (defn foo ...): (defmacro special-fn-spec [] '([bar baz] (println bar baz))) (defn foo ([bar] (foo bar :default)) (special-fn-spec)) The error is: Parameter declaration special-fn-spec should be a vector [Thro