17. Object Reorientation: Classes
Providing Access and Read/Write Control to a Slot
Is this or something equivalent possible using structs? Here is Doug Currie's answer expanded: Zach Beane also gave this answer or one almost like it on comp. Thanks both Zach and Doug! Sign up or log in Sign up using Google.
This dispatch mechanism works at runtime. Adding or removing methods thus may lead to changed effective methods even when the generic function is called with the same arguments at runtime. Changing the method combination also may lead to different effective methods. Any slot can be accessed using the slot-value function or via optionally auto-generated accessor methods. To access it via slot-value you have to know the name of the slot.
CL programmers use the language's package facility to declare which functions or data structures are intended for export. Apart from normal "primary" methods, there also are: The former two are invoked prior to, or after the primary method, in a particular order based on the class hierarchy.
Additionally, the programmer can specify whether all possible primary methods along the class hierarchy should be called or just the one providing the closest match. The Standard Method-Combination provides the primary, before, after and around methods explained above. There are other Method-Combinations with other method types.
New both simple and complex Method-Combinations and method types can be defined. CLOS allows multiple inheritance. When the default order in which methods are executed in multiple inheritance is not correct, the programmer may resolve the diamond inheritance problems by specifying the order of method combinations.
CLOS is dynamic, meaning that not only the contents, but also the structure of its objects can be modified at runtime. CLOS supports changing class definitions on-the-fly even when instances of the class in question already exist as well as changing the class membership of a given instance through the change-class operator.
CLOS also allows one to add, redefine and remove methods at runtime. CLOS is not a prototype language: Classes must be defined before objects can be instantiated as members of that class. The MOP defines a standard interface to the underpinnings of the CLOS implementation, treating classes, slot-descriptions, generic-functions and methods themselves as instances of metaclasses , and allows the definition of new metaclasses and the modification of all CLOS behavior.
The MOP defines the behavior of the whole object system by a set of protocols. These are defined in terms of CLOS. Thus it is possible to create new object-systems by extending or changing the provided CLOS functionality. The various Common Lisp implementations have slightly different support for the Meta-Object Protocol.
The Closer  project aims to provide the missing features. Large parts of the Lisp Machine operating systems and many applications for it use Flavors or New Flavors.
Flavors introduced multiple inheritance and mixins , among other features. Flavors is mostly obsolete, though implementations for Common Lisp do exist. Flavors was using the message passing paradigm. New Flavors introduced generic functions.
CommonLoops was implemented for Common Lisp.