Re: Question concerning eval

2016-01-14 Thread adrian . medina
You need to quote the entire vector `avec`, because otherwise the function you want to bind to `foo` will be evaluated before being evaluated by the `let` special operator, which expects only standard readable object literals to be embedded. Try changing: (def avec ['p true 'foo (fn

Re: Question concerning eval

2016-01-14 Thread gianluca torta
Hi Adrian, with your suggestion it certainly works also with avec' however, I still don't see why the original code from Burt works with avec and does not work with avec' cheers, Gianluca On Thursday, January 14, 2016 at 5:06:02 PM UTC+1, adrian...@mail.yu.edu wrote: > > You need to quote

Question concerning eval

2016-01-14 Thread Burt
Hi, I got an exception using eval and I do not understand why! Can anybody explain what happens? Here is a small piece of code showing the problem: (defn eval-phi [avec phi] (eval `(let ~avec ~phi))) ; The idea of eval-phi is the evaluation of ; arbitrary lists where the symbols are ;

Re: Question concerning eval

2016-01-14 Thread gianluca torta
Hi Burt, I have done some investigation, further reducing your issue to the following: (def g (make-adder 2)) (eval `(let [~'f ~g] (~'f 5))) ; --> error IllegalArgumentException No matching ctor found for class user$make_adder$fn__7609 etc. (defn h [x] (+ x 2)) (eval `(let [~'f ~h] (~'f 5)))

Re: Question concerning eval

2016-01-14 Thread Burt
Hi Adrian, Gianluca, I understand that quoting the entire binding vector avec solves my problem. @Adrian Thanks for the hint. But nethertheless, it's a riddle for me why there's a difference between my original approaches. cheers, Burt -- You received this message because you are

Re: Question concerning eval

2016-01-14 Thread gianluca torta
small update: I found that the problem happens because make-adder returns a closure; with a simple function it works: (defn make-2-adder [] (fn [x] (+ 2 x))) (def g2 (make-2-adder)) (eval `(let [~'f ~g2] (~'f 5))) ; --> 7 On Thursday, January 14, 2016 at 12:52:47 PM UTC+1, gianluca torta