defrecord uses IKeywordLookup's getLookupThunk, but I can't figure out how
to implement it.
Thanks,
Ambrose
On Tue, Sep 24, 2013 at 5:16 PM, Ambrose Bonnaire-Sergeant <
abonnaireserge...@gmail.com> wrote:
> I mean something like what defrecord does:
>
> (defprotocol SumProto
> (sum [x y]))
>
I mean something like what defrecord does:
(defprotocol SumProto
(sum [x y]))
(declare ->Pair)
(deftype Pair [^long a ^long b]
clojure.lang.ILookup
(valAt [this k]
(case k
:a a
:b b))
SumProto
(sum [x y]
(let [new-a (+ (:a x) (:a y))
new-b (+ (:b x) (:b y
Interesting, can you please explain somewhat more?
On Saturday, September 21, 2013 3:19:16 AM UTC+4, Ambrose Bonnaire-Sergeant
wrote:
>
> Just a thought, could implementing IKeywordInvoke and using keywords for
> field lookups speed up compilation?
>
> Thanks,
> Ambrose
>
>
> On Fri, Sep 20, 201
FWIW I observed the same thing profiling 1.5.1 with Yourkit a couple months
ago and tried adding caching to the Clojure compiler, but I wasn't able to
get any speedup. It wasn't clear to me if I messed something up, or if the
profiler was just lying about where the execution time was actually g
Just a thought, could implementing IKeywordInvoke and using keywords for
field lookups speed up compilation?
Thanks,
Ambrose
On Fri, Sep 20, 2013 at 10:01 PM, Dmitry Groshev wrote:
> In this mail I'm talking about Clojure 1.4, however, I believe that the
> issue persists in later versions, too.
In this mail I'm talking about Clojure 1.4, however, I believe that the
issue persists in later versions, too.
I have quite a lot of code of the following form:
(defprotocol sum-proto
(sum [x y]))
(deftype Pair
[^long a ^long b]
sum-proto
(sum [x y]
(let [^Pair y y
new-a