14 ms·
> using structs or other basic data structures instead of objects has visible performance benefits in SBCL if you care about that for some reason. Sure, but re
by whartung 4y ago
> using structs or other basic data structures instead of objects has visible performance benefits in SBCL if you care about that for some reason.
Sure, but recall that CLOS really consists of two distinct components. The class/object system, and generic functions.
Since CLOS is baked into the CL type system, generic functions will happily dispatch against DEFSTRUCT types (as well as all of the other types, not just objects). Add the ability to :include other DEFSTRUCTS, and the idea that when DEFSTRUCT B :includes DEFSTRUCT A, then the type-of of B is both as a B struct and an A struct, then you get back alley inheritance using structures.
So, now (in theory) you get the efficiency of DEFSTRUCT, but all of the dynamic dispatch giddy goodness of DEFMETHOD, when and if you want to use it.
It can be a really nice compromise.
- pfdietz 4y agoGeneric functions in Common Lisp dispatch against "all the other classes", not "all the other types". Every class in CL is a type, but not every type is a class.