3 ms·
fwiw, clojure supports polymorphism. http://clojure.org/multimethods http://clojure.org/multimethods I encountered this recently but I'll try to give a (bad)
by deadghost 12y ago
fwiw, clojure supports polymorphism.
http://clojure.org/multimethods http://clojure.org/multimethods
I encountered this recently but I'll try to give a (bad) explanation.
You'll call `function(thing, arg1, arg2, arg3);`.
Another function will run on the arguments and return a dispatch value. For example, it will check what `thing` is and return `struct`. The `struct` version of that function is then run on the args and gives you your value.
In this way you can define several `close` functions based on dispatch value instead of one monolith nested if/else `close`.
I'm on the opposite side of the fence, OOP has never ever appealed to me. "Why would anyone want to use this crazy mess?" kind of thing. I'm sure I can learn to appreciate it with time but it's not a native paradigm to my mind.
I only have experience with lisps when it comes to functional programming but the reason I enjoy it is that it's simple. You have functions and you have data. Functions transform data to more data and the two aren't tightly bound. If you pass a function a value it will always return the same result if you pass it the same value.
THE clojure video: http://www.infoq.com/presentations/Simple-Made-Easy http://www.infoq.com/presentations/Simple-Made-Easy (I don't think he even says the word clojure in the entire hour presentation.)