Making Instances


(defun make-instance (class rest initargs)
  (if (classp class)
    (let ((instance (make-atom class)))
      (addslots instance class initargs)
      (setf (get instance 'class) class)
      instance) ))


(defun addslots (instance class initargs)
  (let (initarg)
    (dolist (super (get class 'supers))
      (addslots instance super initargs))
    (dolist (slot (get class 'slots))
      (setf (get instance (car slot))
            (or (and (setq initarg
                           (getf (cdr slot)
                                 ':initarg))
                     (getf initargs initarg))
                (eval (getf (cdr slot)
                            ':initform)))) ) ))

Contents    Page-10    Prev    Next    Page+10    Index