> Is the following behavior correct or a bug:
>
> user> (defrecord Example [data] clojure.lang.IFn (invoke [this] this)
> (invoke [this n] (repeat n this)))
> user.Example
> user> (def e (Example. "I am e"))
> #'user/e
> user> (e 2)
> (#:user.Example{:data "I am e"} #:user.Example{:data "I am e"})
> user> (def some-es (e 5))
> ; Throws java.lang.AbstractMethodError
>
> I can't tell if I am doing something wrong with respect to the IFn
> definition, or if I am encountering a bug.
I think you need to implement applyTo for a properly working IFn
implementation:
(defrecord Example [data] clojure.lang.IFn
(invoke [this] this)
(invoke [this n] (repeat n this))
(applyTo [this args] (clojure.lang.AFn/applyToHelper this args)))