:46, Tassilo Horn wrote:
> Alexey Cherkaev writes:
>
> Hi Alexey,
>
> > If you have a protocol
> >
> > (defprotocol Foo (foo [x] [x y]))
> >
> > and implement it for the record
> >
> > (defrecord Bar [p q r]
> > Foo
> >
Hi all,
If you have a protocol
(defprotocol Foo (foo [x] [x y]))
and implement it for the record
(defrecord Bar [p q r]
Foo
(foo [x] x)
(foo [x y] [x y]))
you write each method separately. The same is true for extend-type. Yet, if
you use extend-protocol syntax is more like usual Clojure
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
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)