Does there exist anything like CLOS (Common Lisp Object System) for Clojure? If there isn't, how hard would it be to write one? Thanks in advance.
-- Eric Grindt
Does there exist anything like CLOS (Common Lisp Object System) for Clojure? If there isn't, how hard would it be to write one? Thanks in advance.
-- Eric Grindt
Have you considered Clojure's data types (especially defrecord
), protocols, and multimethods? All three will always be more idiomatic within Clojure than a port of CLOS on top of these mechanisms.
Clojure does not have CLOS and doesn't want CLOS but you could implement it.
Clojure wants to be immutable so to have mutible OO would be kind of stupid but you can have a kind of OO.
With these three things you should be able to fulfill all your needs but most of the times its best to just use normal functions and the standard datastructures.
Clojure itself doesn't have an object system, for two reasons:
But, you can obviously implement an object system in Clojure. Clojure is, after all, Turing-complete.
Mikel Evins is working on a new approach to OO which he calls Categories. He has implementations for several Lisps, including Clojure (although not all the ports are guaranteed to be up-to-date all the time).
Categories is slowly being subsumed by Bard, a new Lisp dialect that Mikel is designing, which has Categories built in. (Which then, in turn, may become the implementation language for Closos, an idea Mikel had for how to design an operating system.)