Object System Lisp
overviewProgrammer interface conceptsClassesSlotsInheritanceGeneric functions and methodsIntroduction to generic functionsIntroduction to methodsStandard method classes and method objectsObject creation and initializationExtensions
Programmer interface conceptsThe common lisp open system(CLOS) is an object-oriented extension to Common Lisp.In the standard programmer interface of CLOS, we have,The first part, Programmer interface concepts
The second part, Functions in  programmers interface, contains a description of the functions and macros in CLOS programmers interface.
The third part, common lisp object system meta-object protocol, explains how the CLOS has to be customized.classesA class is an object that determines the structure and the behavior of a set of other objects, which are called its instances.A class can inherit structure and behavior from other classes.A class whose definition refers to other classes for the purpose of inheriting The classes that are designated for the purpose of inheritance are said to be the super classes of the inheriting class.
The function class-name takes a class object and returns its nameEach class has a class precedence list, which is the total ordering on the set of the given class and its super classes.The total ordering is a list ordered from the most specific to least specific.
Defining classesThe macro defmacro is used to define a new named class.The definition includesName of the new class.
List of the directed super classes of the new class
A set of slot specifiers
A set of class optionsThe generic function make-instance creates and returns a new instance of a class.
slotsAn object that has standard-class as its metaclass has zero or more slots.The slots of an object are determined by the class of the object.Each slot can hold one value.The default initial value of a slot is defined by the :initform slot option.
A local slot is the one that is visible to exactly one instance, namely the one in which the slot is allocated.A shared slot is defined to be a slot that is visible to more than one instance of a given class and its subclassesA slot can be accessed in two ways: by the use of primitive function slot-value.
By use of generic functions generated by the defclass form.InheritanceA class can inherit methods, slots and some defclass options from its super classes.A subclass inherits methods in the sense that any method applicable to all instances of a class is also applicable to all instances of any subclass of that class.Inheritance of class options:The :default-initargs class option is inheritedEx: ( defclass c1 ()        ((s1 :initform 5.4 :type number)          (s2 :allocation :class))) Instances of class c1 have a local slot named s1, whose default initial value is 5.4
s1 should always be a number.
Class c1 also has a shared slot named s2.(defclass c2 (c1)       ((s1 :initform 5 :type integer)        (s2 :allocation :instance)        (s3 :accessor c2-s3)))There is a local slot named s1 in instances of c2.
The default initial value of s1 is 5.
The value of s1 will be of type integer.
There are also local slots of named s2 and s3 in instances of c2.
The class c2 has a method for c2-s3 for reading the value of slot s3.Determining the class precedence ListThe defclass form for a class provides a total ordering on that class and its direct super classes.This ordering is called the local precedence order.The class precedence list for a class C is a total ordering on C and its super classes that is consistant with the local precedence orders for C and its super classes.
Class precedence list ArrayBit-vectorCharacterComplexConsFloatFunction*Hash-table*IntegerListNull
NumberPackage*Pathname*Random-state*RatioRationalReadtable*SequenceStream*StringSymboltvector
Introduction to generic functionsA generic function object contains a set of methods, lambda-list, a method combination type, and other information.A generic function can be given a global name using the defmethod and defgeneric construct.A generic function can be given a local name using generic-flet, generic-labels, or with-added-method special forms.
Introduction to methodsA method object contains a method function, a sequence of parameter specializes which specify when the given method is applicable, a lambda-list and a sequence of qualifiers.A method-defining form contains the code that is to be run when the arguments for the generic function cause the method that it defines to be invoked.
Congruent lambda-list for all methods of a generic function Each lambda-list must have the same number of required parametersEach lambda-list must have the same number of optional.If any lambda-list mentions &rest or &key, each lambda-list must mention one or both of them.If the generic function lambda-list mentions &key, each method must accept all of the keyword names mentioned after &key, either  by accepting them explicitly, by specifying &allow-other-keys, or by specifying &rest but and &key.
Standard method combinationStandard method combination is supported by the class standard-generic-function.Primary functions define the main action of the effective method, while auxiliary methods modify that action in one of three ways:A primary method has no method qualifier.An auxiliary method is a method whose method qualifier is :before, :after, or :aroundThe macro define-method-combination defines new forms of method combinations.It provides an effective method for customizing the production of the effective method.

LISP:Object System Lisp

  • 1.
  • 2.
    overviewProgrammer interface conceptsClassesSlotsInheritanceGenericfunctions and methodsIntroduction to generic functionsIntroduction to methodsStandard method classes and method objectsObject creation and initializationExtensions
  • 3.
    Programmer interface conceptsThecommon lisp open system(CLOS) is an object-oriented extension to Common Lisp.In the standard programmer interface of CLOS, we have,The first part, Programmer interface concepts
  • 4.
    The second part,Functions in programmers interface, contains a description of the functions and macros in CLOS programmers interface.
  • 5.
    The third part,common lisp object system meta-object protocol, explains how the CLOS has to be customized.classesA class is an object that determines the structure and the behavior of a set of other objects, which are called its instances.A class can inherit structure and behavior from other classes.A class whose definition refers to other classes for the purpose of inheriting The classes that are designated for the purpose of inheritance are said to be the super classes of the inheriting class.
  • 6.
    The function class-nametakes a class object and returns its nameEach class has a class precedence list, which is the total ordering on the set of the given class and its super classes.The total ordering is a list ordered from the most specific to least specific.
  • 7.
    Defining classesThe macrodefmacro is used to define a new named class.The definition includesName of the new class.
  • 8.
    List of thedirected super classes of the new class
  • 9.
    A set ofslot specifiers
  • 10.
    A set ofclass optionsThe generic function make-instance creates and returns a new instance of a class.
  • 11.
    slotsAn object thathas standard-class as its metaclass has zero or more slots.The slots of an object are determined by the class of the object.Each slot can hold one value.The default initial value of a slot is defined by the :initform slot option.
  • 12.
    A local slotis the one that is visible to exactly one instance, namely the one in which the slot is allocated.A shared slot is defined to be a slot that is visible to more than one instance of a given class and its subclassesA slot can be accessed in two ways: by the use of primitive function slot-value.
  • 13.
    By use ofgeneric functions generated by the defclass form.InheritanceA class can inherit methods, slots and some defclass options from its super classes.A subclass inherits methods in the sense that any method applicable to all instances of a class is also applicable to all instances of any subclass of that class.Inheritance of class options:The :default-initargs class option is inheritedEx: ( defclass c1 () ((s1 :initform 5.4 :type number) (s2 :allocation :class))) Instances of class c1 have a local slot named s1, whose default initial value is 5.4
  • 14.
    s1 should alwaysbe a number.
  • 15.
    Class c1 alsohas a shared slot named s2.(defclass c2 (c1) ((s1 :initform 5 :type integer) (s2 :allocation :instance) (s3 :accessor c2-s3)))There is a local slot named s1 in instances of c2.
  • 16.
    The default initialvalue of s1 is 5.
  • 17.
    The value ofs1 will be of type integer.
  • 18.
    There are alsolocal slots of named s2 and s3 in instances of c2.
  • 19.
    The class c2has a method for c2-s3 for reading the value of slot s3.Determining the class precedence ListThe defclass form for a class provides a total ordering on that class and its direct super classes.This ordering is called the local precedence order.The class precedence list for a class C is a total ordering on C and its super classes that is consistant with the local precedence orders for C and its super classes.
  • 20.
    Class precedence listArrayBit-vectorCharacterComplexConsFloatFunction*Hash-table*IntegerListNull
  • 21.
  • 22.
    Introduction to genericfunctionsA generic function object contains a set of methods, lambda-list, a method combination type, and other information.A generic function can be given a global name using the defmethod and defgeneric construct.A generic function can be given a local name using generic-flet, generic-labels, or with-added-method special forms.
  • 23.
    Introduction to methodsAmethod object contains a method function, a sequence of parameter specializes which specify when the given method is applicable, a lambda-list and a sequence of qualifiers.A method-defining form contains the code that is to be run when the arguments for the generic function cause the method that it defines to be invoked.
  • 24.
    Congruent lambda-list forall methods of a generic function Each lambda-list must have the same number of required parametersEach lambda-list must have the same number of optional.If any lambda-list mentions &rest or &key, each lambda-list must mention one or both of them.If the generic function lambda-list mentions &key, each method must accept all of the keyword names mentioned after &key, either by accepting them explicitly, by specifying &allow-other-keys, or by specifying &rest but and &key.
  • 25.
    Standard method combinationStandardmethod combination is supported by the class standard-generic-function.Primary functions define the main action of the effective method, while auxiliary methods modify that action in one of three ways:A primary method has no method qualifier.An auxiliary method is a method whose method qualifier is :before, :after, or :aroundThe macro define-method-combination defines new forms of method combinations.It provides an effective method for customizing the production of the effective method.