Table of Contents
Allegro CL Certification Program
1. Define a Class
2. Make an Instance
3. Define a Subclass
4. Use Methods
5. Use Method Combination
6. Initialize Instances
7. Use Slot-Value
About Slot-Value
8. Use SETF methods
9. Use Multiple Dispatch
10. Use Multiple Inheritance
Allegro CL Certification Program
Common Lisp Object System
Terminology
Classes and Instances
Slots
Class Inheritance
CLOS Supports Multiple Inheritance
Supporting Type-Specific Behavior
CLOS Generic Functions Support Modular Definitions
CLOS Generates Dispatch Code
Dispatch on Multiple Arguments
Method Combination
Class Precedence Lists
Defining a class
Defining a slot
defclass Options
Defining the Interface
Defining the Implementation
Make-Instance
Accessing and Changing Slot Values
Example - Squares
Constructor Function
Example - Rectangles
Example - Method
Example - Method Inheritance
Getting the class of an object
DESCRIBE
SLOT-VALUE
Other slot functions
:ACCESSOR Slot Option
:INITFORM Slot Option
:INITARG Slot Option
:ALLOCATION slot option
Alternate approach
Methods
Multiple Dispatch
Dispatching on Class T
Dispatch Using EQL
Dispatch Using EQL, cont�d.
:BEFORE and :AFTER methods
Order of Before and After
:AROUND methods
Primary methods call-next-method
Call-next-method with arguments
call-next-method example
SETF Methods
initialize-instance
print-object
print-object Support
Inheritance and Combining Methods
Class Precedence List
Class Precedence Lists
Precendence example
Putting it all together
Some Guidelines on API
Reasons to Use Class Hierarchies
Allegro CL Certification Program
Congruence of Method Argument Lists
Congruency examples
Keyword Congruency Examples
Specialization of Slots
Using a Shared Slot
Inheritance of Shared Slots
Specializing Shared Slots to Local Slots
defgeneric
:argument-precedence-order
Changing Generic Functions
Changing Methods
find-class
class-name
class-of
Almost All Built-in Types Have Corresponding Classes
Inheritance for Built-in Types
Defstruct defines classes
But Structure Accessors are not Generic
Allegro CL Certification Program
Avoid typep
Avoid Slot-value
Avoid Multipurpose Slots
Use Constructors
Add Print-object Methods
Use EQL Methods With Symbols
Peter Norvig�s Lisp Style Maxims
The Goal
[email protected]
|