Changeset 284


Ignore:
Timestamp:
Jan 13, 2004, 5:04:46 PM (21 years ago)
Author:
Gary Byers
Message:

Check initargs via DESTRUCTURING-BIND in %SHARED-INITIALIZE.
ENSURE-CLASS-FOR-DEFCLASS and
*defclass-redefines-improperly-named-classes-pedantically*. (SETF
CLASS-NAME) isn't an accessor; the real method uses
REINITIALIZE-INSTANCE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-clos.lisp

    r242 r284  
    1919;;; At this point in the load sequence, the handful of extant basic classes
    2020;;; exist only in skeletal form (without direct or effective slot-definitions.)
    21 
     21(in-package "CCL")
    2222
    2323(defun extract-slotds-with-allocation (allocation slotds)
     
    5858  (unless (or (listp slot-names) (eq slot-names t))
    5959    (report-bad-arg slot-names '(or list (eql t))))
    60   (unless (plistp initargs) (report-bad-arg initargs '(satisfies plistp)))
     60  ;; Check that initargs contains valid key/value pairs,
     61  ;; signal a PROGRAM-ERROR otherwise.  (Yes, this is
     62  ;; an obscure way to do so.)
     63  (destructuring-bind (&key &allow-other-keys) initargs)
    6164  (let* ((wrapper (instance.class-wrapper instance))
    6265         (class (%wrapper-class wrapper)))
     
    654657  (apply #'ensure-class-using-class (find-class name nil) name keys))
    655658
     659(defparameter *defclass-redefines-improperly-named-classes-pedantically*
     660   t
     661  "ANSI CL expects DEFCLASS to redefine an existing class only when
     662the existing class is properly named, the MOP function ENSURE-CLASS
     663redefines existing classes regardless of their CLASS-NAME.  This variable
     664governs whether DEFCLASS makes that distinction or not.")
     665
     666(defun ensure-class-for-defclass (name &rest keys &key &allow-other-keys)
     667  (record-source-file name 'class)
     668  ;; Maybe record source-file information for accessors as well
     669  ;; We should probably record them as "accessors of the class", since
     670  ;; there won't be any other explicit defining form associated with
     671  ;; them.
     672  (let* ((existing-class (find-class name nil)))
     673    (when (and *defclass-redefines-improperly-named-classes-pedantically*
     674               existing-class
     675              (not (eq (class-name existing-class) name)))
     676      ;; Class isn't properly named; act like it didn't exist
     677      (setq existing-class nil))
     678    (apply #'ensure-class-using-class existing-class name keys)))
     679
    656680
    657681(defun slot-plist-from-%slotd (%slotd allocation)
     
    848872 :direct-slots
    849873 `((:name prototype :initform nil :initfunction ,#'false)
    850    (:name name :initargs (:name) :initform nil :initfunction ,#'false :readers (class-name) :writers ((setf class-name)))
     874   (:name name :initargs (:name) :initform nil :initfunction ,#'false :readers (class-name))
    851875   (:name precedence-list :initargs (:precedence-list) :initform nil  :initfunction ,#'false)
    852876   (:name own-wrapper :initargs (:own-wrapper) :initform nil  :initfunction ,#'false :readers (class-own-wrapper))
     
    14561480  `(ensure-slot-id ,(slot-id.name s)))
    14571481
     1482
     1483(defmethod (setf class-name) (new (class class))
     1484  (reinitialize-instance class :name new)
     1485  new)
Note: See TracChangeset for help on using the changeset viewer.