Thanks, Nicola! It solved it. When I looked at docs, I couldn't figure out the role of `applyTo`. Well, now I know.
On Thursday, April 23, 2015 at 1:47:11 PM UTC+2, Nicola Mometto wrote: > > > You're not implementing IFn.applyTo, you should. > > Why applyTo is used in the second example while invoke is used in the > other cases has to do with implementation details of how def expressions > are compiled/evaluated. > > Alexey Cherkaev writes: > > > Hi, > > > > I have encountered the problem with Clojure 1.6.0, when I create the > record > > that implements IFn. > > > > For example, > > > > (defrecord Foo [x] > > clojure.lang.IFn > > (invoke [_ f] (f x))) > > > > Than create an instance of this record: > > > > (def f (->Foo 10)) > > > > And we can call it without a problem: > > > > user=> (f inc) > > 11 > > > > Yet, if you try to define a value to keep the result, compiler throws an > > error: > > > > user=> (def z (f inc)) > > > > CompilerException java.lang.AbstractMethodError, > > compiling:(form-init4774307052978984831.clj:1:8) > > > > There is workaround: create local binding first and then assign the > value > > to a global variable: > > > > user=> (def z (let [temp (f inc)] temp)) > > #'user/z > > user=> z > > 11 > > > > Is this a bug or I don't fully understand why you can't do that? > > > > Cheers, Alexey > > -- > -- 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.