On May 4, 2016, at 5:28 PM, Johannes <bra...@nordakademie.de> wrote:

> Maybe you are right. But I've deliberately given function objects to eval 
> often without any problems until I used functions of some special kind. I do 
> not understand why the behavior for the 2 versions of the function f- I've 
> shown is different.

Oops, I think I missed the main problem: you were passing a pre-evaluated map 
object directly to eval. What eval really wants is the kind of thing that the 
reader returns after it reads a string. The reader doesn’t evaluate symbols, 
like f-. That’s eval’s job. When the reader sees the string f-, it returns the 
symbol f-. You passed eval the actual function object, not the symbol f-. Eval 
wants to see the symbol; it will replace it with the object that it evaluates 
to.

In other words, I think you just forgot to quote the expressions that you were 
passing to eval. Adding the quote, here’s what I get:

user=> (def f- (let [v 1
  #_=>               f (fn [x] v)] f))
#'user/f-

user=> (eval '{:d f-})
{:d #function[user/fn--10235/f--10236]}

user=> (def f- (let [v 1
  #_=>               f (fn [x] x)] f))
#'user/f-

user=> (eval '{:d f-})
{:d #function[user/fn--10243/f--10244]}

--
Ben Kovitz
http://mypage.iu.edu/~bkovitz/


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to