On Saturday, August 4, 2012 9:57:55 PM UTC-4, tbc++ wrote: > > Warren, I can't speak for others, but I can say that personally one of the > reasons I love Clojure so much is that it doesn't try to be a OOP language, > instead it cleanly separates data from logic. Clojure is not a OOP language > and (hopefully) will never attempt to be so.
I don't think OOP and non-OOP is so clear cut. I am just saying, OOP in the field consists various ideas and patterns, and we can borrow the good part. This also comes from my bielief that languages is for providing abstractions and patterns (hence the all-mighty all-freedom assembly is not a good language because it provides no abstraction and patterns), and it is hard for me to believe OOP is just a bag of all bad patterns collected by stupid people. It can not be all good (or suitable in our case) either of course. But this separation of logic and data should be very, very carefully > examined. Here's an example: > > (defprotocol IFoo > (foo-func [this])) > > (defrecord Foo [num] > IFoo > (foo-func [this] num)) > > (defn foo [num] > (Foo. num)) > > This is the idiomatic way to write Clojure code, and if you read the .java > files in Clojure you'll see that they are laid out the same way. Many > classes have a static "create" function that does the actual data > processing, while the constructors do simple assignment. So what's so great > about all this? To the OOP programmer you would see this as "an interface, > a object with a overriding member, and a factory function". But this is > simply not the case. What we are defining, is a collection of polymorphic > functions (IFoo), a data-structure that installs a function into this > polymorphic function, and a constructor function. > > So even here, where there appears to be OOP style abstractions and > conventions, it's really just syntactic sugar over FP code. Clojure is less > of a OOP language than most people realize. > > Well, I like sugars! You can call my proposal as syntatic sugars too if it is included in the language. I don't really care how it is implemented under the hood. I care about the abstraction and patterns. > Timothy > -- 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