Chad P. firstname.lastname@example.org writes:
object(s) you pass as arguments. There’s no concept of a receiver though.
So, basically, instead of real methods, CLOS just uses . . . what?
Parametric polymorphism? This isn’t meant as a challenge or complaint,
but rather just a question so I’ll understand it better:
The following begins with a good overview of the rational behind the use
of generic functions in CLOS instead of using a message passing system
as used in ruby.
linked to from
It makes the good point that generic functions are a natural solution in
any lisp. The paper states…
| Furthermore, in Common Lisp, arithmetic operators are already
| generic in a certain sense. The expression
| (+ x y)
| does not imply that x and y are of any particular type, nor does it
| imply that they are of the same type. For example, x might be an
| integer and y a complex number, and the + operation is required to
| perform the correct coercions and produce an appropriate result.
| Because the Object System is a system for Common Lisp, it is
| important that generic functions be first-class objects and that the
| concept of generic functions be an extension and a generalization of
| the concept of Common Lisp functions. In this way, the Object System
| is a natural and smooth extension of Common Lisp.
Also, CLOS contains mechanisms for implementing a message-passing based
object system. Again from the paper…
| Despite the advantages of generic functions, there may at times be
| reasons for preferring a message-passing style; such a style can be
| implemented by means of generic functions or by means of the Common
| Lisp Object System Meta-Object Protocol.
I would very much like to see any implementation of a ruby-like message
based object system using CLOS.
What about CLOS makes it “object oriented”?
The fact that it provides for the creation of objects which are
instances of classes, and provides for inheritance between classes.