On Mar 3, 7:47 pm, cageface <[email protected]> wrote: > I've been reading through the examples of "OO" in clojure using multi- > methods and they certainly seem very flexible and powerful. I'm > wondering, however, how people handle interface & library design. If > people can implement "objects" as maps, structs, or just about > anything else you can discriminate on via a dispatch function, how do > you handle code reuse and sharing of libraries. If we're all using our > own home-grown OO systems how do we communicate? > > Is this something that the deftype/protocol proposals are meant to > address or do people just work around it in other ways or is it just > not a real issue in practice?
Well, it seems to me that the "universal interface" is the sequence. Turns out many things can be represented as sequences. :) And since maps are just collections of key/value pairs, very generic code can be written to process them, too. As long as the wanted keys are there, any extra information the map might be carrying can often be ignored. deftype will allow people to define their own types for data that would be inefficient to store in a map. They will still (optionally) expose a map-like interface, so any generic map-processing code is not necessarily obsoleted by them. Protocols on the other hand allow you to define interfaces which can be implemented "after the fact", hopefully making interoperability easier. -- 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
