4 ms·
A Brief Guide to CLOS
- flavio81 9y agoGood point in this guide: A little known fact is that, in CL, it's also "objects all the way down": It turns out that all Common Lisp data objects are instances of classes. Consequently, you can define methods for all kinds of existing object types (such as numbers, hash-tables, and vectors); you don't have to use defclass at all before defining methods. Moreover, the objects created using defclass and make-instance can be used with ordinary Lisp functions, not only with methods. To find the class of an object, use the function class-of. For example: Expression Value (class-of 'a) #<Built-In-Class SYMBOL> (class-of "a") #<Built-In-Class STRING> (class-of 12) #<Built-In-Class INTEGER> (class-of '(a b)) #<Built-In-Class CONS> (class-of '#(a b c)) #<Built-In-Class VECTOR>