Hi, Am Dienstag, 22. Mai 2012 00:08:52 UTC+2 schrieb puzzler:
> Mergeable maps are a good idea, but the current way of doing things > steers people away from that solution and requires too much > forethought to actively plan for reuse. I wonder why the current way of doing things “steers away” people from using extend. extend is simply the default. Period. Implementing things directly in a deftype or a defrecord should be the last resort if performance requires it. You loose not only the code reuse part when implementing things directly in the types, you also welcome back name clashes. user=> (ns foo) nil foo=> (defprotocol Foo (foo [this])) Foo foo=> (ns bar) nil bar=> (defprotocol Bar (foo [this])) Bar bar=> (in-ns 'user) #<Namespace user> user=> (defrecord Data [x] foo.Foo (foo [this] :foo) bar.Bar (foo [this] :bar)) CompilerException java.lang.ClassFormatError: Duplicate method name&signature in class file user/Data, compiling:(NO_SOURCE_PATH:6) Or take mutually recursive types. With extend this is no problem at all. With direct definition you have to introduce manual factories with declare to break the cycles. Everyone just reiterates the mantra “It's slower! It's slower! It's slower!”, but no one talks about the trade-offs. And I bet only a very small fraction ever checked what “slower” means in their specific use case. The problem is not the current implementation. That is perfectly fine. The problem is a questionable golden idol called “performance” paired with lack of sorrow research. Kind regards Meikel -- 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