Re: invoking macros from Java

2009-10-30 Thread Rich Hickey
On Wed, Oct 28, 2009 at 12:21 AM, Alex Osborne wrote: > > Jeff Brown wrote: > >> I can invoke a function using Java code that looks something like this... >> >> Reader reader = new FileReader("clj/demo.clj"); >> Compiler.load(reader); >> Var var = RT.var("demo", "add_numbers"); >> Object result =

Re: invoking macros from Java

2009-10-27 Thread Alex Osborne
Jeff Brown wrote: > I can invoke a function using Java code that looks something like this... > > Reader reader = new FileReader("clj/demo.clj"); > Compiler.load(reader); > Var var = RT.var("demo", "add_numbers"); > Object result = var.invoke(4, 7); > System.out.println("Result: " + result); >

invoking macros from Java

2009-10-27 Thread Jeff Brown
If I have something like this... (ns demo) (defn add_numbers ([x] x) ([x & rest-args] (reduce + (cons x rest-args (defmacro silly_adder [sum] (let [addend# (for [i (range sum)] 1)] `(add_numbers ~...@addend#))) (defmacro even_sillier_adder [sum] `(silly_adder ~(+ sum 5))) I