If you are dispatching on types, use protocols. It's much faster.
Luc P
> I've experienced rewriting my ClojureScript code into multimethods
> base.
> I'd share my results.
>
> Initially I implemented polymorphism behavior as simple hashmap like
> this:
>
> (def parent
> {:foo (fn [x] ...)
> :bar (fn [x] ...)})
> (def child
> (merge parent {:foo (fn [x] ...)}))
>
> For some reason, I didn't choose protocols.
> Then I found multimethods support hierarchy system and rewrote the
> code into 42 defmulti and 64 defmethod.
>
> After rewriting, I noticed that rewritten code is too slow as I can
> see a displaying delay without measurement.
>
> Profiles in Chrome (Ignore first (program) line.)
> Simple hashmap approach: http://twitpic.com/88wvyl
> Multimethods approach: http://twitpic.com/88wwd8
>
> So I put the code back.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
--
Softaddicts<[email protected]> sent by ibisMail!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en