Maybe some macros can help. But if it is a good and common pattern, then it should be included as part of the the language. One thing I am glad to see in Clojure is it absorbed some known good macros in Common Lisp (like "awhen" becomes "when-let") so people don't need to re- invent the wheels again and get things so fragmented (which is something I am very frustrated with Common Lisp)
On May 21, 7:23 pm, kovas boguta <kovas.bog...@gmail.com> wrote: > On Mon, May 21, 2012 at 6:08 PM, Mark Engelberg > > <mark.engelb...@gmail.com> wrote: > > I never said I want inheritance. I want convenient reuse of partial > > implementations. Inheritance is one way to achieve it, but I'd like to > > think that Clojure can find a better way. > > We also have macros. > > You can always make your own > > (defmytype TypeName ...) > > and make compile to a deftype that rolls in the protocol > implementations you want to reuse. > > I believe the current mechanisms > > > > > > > > > are insufficient. Copy and paste is not good enough. 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. If I > > implement a protocol inside of defrecord, all that implementation is "locked > > inside" and no one can get at it or reuse it in other contexts. This flies > > in the face of so many design principles of Clojure which generally eschew > > unnecessary encapsulation and privacy to make it easy to get at, reuse, and > > extend data and functions. > > > As I proposed in an earlier email, one brainstorm I have about this is: > > > (get-protocol-implementation <type> <protocol-or-interface>) gives you back > > a mapping of the functions used by that type to implement that protocol. > > Also, we need a way to use mappings of functions inside of > > defrecord/deftype, not just extend, if that is technologically feasible. > > > I am genuinely interested in further brainstorms on the topic of how to > > encourage reuse of protocol implementations *without* inheritance. > > > -- > > 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 -- 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