4 ms·
What are the similarities and differences between working with a CLU-type type/cluster separation for fields and methods, and a CLOS-style multi-method approach
by lmkg 17y ago
What are the similarities and differences between working with a CLU-type type/cluster separation for fields and methods, and a CLOS-style multi-method approach, which has methods and generics standing free from objects and classes? It seems like CLU follows a more traditional single-dispatch paradigm, with the fields and the methods in different layers but bundled together, while CLOS separates the methods not just from the fields but from everything. But I haven't worked with either, so I'm just guessing. Can anyone comment from experience?
- mnemonicsloth 17y agoI'm clueless about CLOS and just learning Clojure. Corrections solicited, grain of salt, yadda yadda: 1. Clojure already provides multimethods, which can dispatch CLOS-style, based on number/type of their arguments, or by an arbitrary predicate. 2. To use your wording, while CLOS separates methods from "everything", Clojure multimethods are even separated from classes. Other than being type-aware enough to do dispatch, multimethods are conceptually just functions with some extra testing on the front end. 3. Implementation-wise, things seem to be different. Perusing the links below, it seems the new functionality is intended to preserve dynamism/performance when Java and Clojure objects interact. 4. Grouping functions into logical chunks seems to be the other idea behind protocols.