r/Clojure • u/fadrian314159 • Apr 22 '26
Introducing FOL (Functional Object Lisp)
/r/lisp/comments/1ssex0s/introducing_fol_functional_object_lisp/
14
Upvotes
r/Clojure • u/fadrian314159 • Apr 22 '26
View all comments
Show parent comment
3
u/fadrian314159 Apr 22 '26
I noticed I didn't reply to one of your questions, namely how I respond to Hickey's CLOS objections.
The first objection - that CLOS objects are mutation-based - can be answered by making objects immutable. FOL makes all objects immutable by default and uses the MOP to lock out mutation after initialization. The transpiler signals errors if one tries to use setf or any other mutation functions (replaca, etc.). This essentially makes all objects immutable value objects.
Hickey's second objection is that CLOS conflates data with behavior, turning objects into "Blobs" that are hard to use in different parts of the system. I have two comments on this. The first is on the nature of coupling. In languages where the method definitions are included in the class definition, it's clear that one cannot use the method outside the context of the class. These are definitely tightly coupled and cannot be used without forming blobs. However, in CLOS, the only thing that a defclass does is attach an identifier to a set of slots. This identifier can then be used to tag parameters in methods. Once a class is defined, it is easy to attach different names to them, say for different uses. It is the difficulty to detach the objects from a given method that causes the coupling. Also, was it really that big of a concern? If it was, Hickey should have disallowed other causes of blobification - such as allowing functional data values to be included in data maps destined for use as objects.
Hickey:s third objection to CLOS' use was that it was a complexity trap - that multiple inheritance and the MOP's form of multimethods, although powerful, allowed the user to build overly complex structures in data and code and that these designs tended to hide this complexity leading to code that was inherently difficult to understand. Our argument against this is that users tend not to use these advanced features in practice, unless they are necessary and, when they are necessary, their lack leads to code that is actually more complex. In our paper, we show two different programming patterns for everyday uses that are enabled by an :around method. Because this feature is not present in Clojure, the Clojure user must actually write more (and more easy to be incorrect) code.
The final objection we were aware of was that it would be difficult to implement a performant CLOS with dynamic dispatch and a MOP on the JVM. This we will not dispute. We sidestepped the issue by transpiling to a system that had already shown its ability to support dynamic objects with multiple inheritance and a MOP - Common Lisp.
Well, that's it. If you can think of other objections Rich had, or if you think my responses are bogus, let me know. I still have time to modify my paper.