[Next] [Previous] [Up] [Top] [Contents] [Index]

Classes and instances

Redefining a class

To redefine a class, simply edit the previous definition of the class and execute it again. Here is a revised definition of fourth-grader, adding a school slot:

? (defclass fourth-grader () 
    ((teacher :initarg :teacher  
              :initform "Mrs. Marple")
     (school :initarg :school  
             :initform "Lawrence School")
     (name :initarg :name)
     (age :initarg :age :initform 9)))
#<STANDARD-CLASS FOURTH-GRADER>

After the redefinition, all instances of fourth-grader, including ones already created, will have a school slot.

? (slot-value john 'school)
"Lawrence School"

When you create a new instance, you can specify a value for the school slot.


Gettmg Started with MCL - 19 OCT 1996
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker