Changeset 8623


Ignore:
Timestamp:
Feb 29, 2008, 6:16:12 AM (14 years ago)
Author:
gb
Message:

Define *SEALED-CLOS-WORLD*, which defaults to NIL. When non-NIL.
attempts to define/redefine classes and methods are disallowed.

In MULTI-METHOD-INDEX, use the low-level accssor %METHOD.QUALIFIERS
rather than %METHOD-QUALIFIERS (which, after CLOS is bootstrapped,
becomes METHOD-QUALIFIERS.) The low-level accessor and the GF
should always return the same result (because STANDARD-METHOD
is a primary class); avoid the use of the GF here, since this is
used in restoring the (possibly "snapped") dcode of generic
functions, including #'METHOD-QUALIFIERS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-clos-boot.lisp

    r8421 r8623  
    689689      (mapcar #'canonicalize-specializer specializers))))
    690690
     691(defparameter *sealed-clos-world* nil "When true, class and method definition -at least - are disallowed.")
     692
    691693(defun ensure-method (name specializers &rest keys &key (documentation nil doc-p) qualifiers
    692694                           &allow-other-keys)
    693695  (declare (dynamic-extent keys))
    694   (setq specializers (canonicalize-specializers specializers))
    695   (let* ((gf (ensure-generic-function name))
    696          (method (apply #'%make-method-instance
    697                         (%gf-method-class gf)
    698                         :name name
    699                         :specializers specializers
    700                         keys))
    701          (old-method (when (%gf-methods gf)
    702                        (ignore-errors
    703                          (find-method gf qualifiers specializers nil)))))
    704 
    705     (%add-method gf method)
    706     (when (and doc-p *save-doc-strings*)
    707       (set-documentation method t documentation))
    708     (record-source-file method 'method)
    709     (when old-method (%move-method-encapsulations-maybe old-method method))
    710     method))
     696  (if *sealed-clos-world*
     697    (error "Method (re)definition is not allowed in this environment.")
     698    (progn
     699      (setq specializers (canonicalize-specializers specializers))
     700      (let* ((gf (ensure-generic-function name))
     701             (method (apply #'%make-method-instance
     702                            (%gf-method-class gf)
     703                            :name name
     704                            :specializers specializers
     705                            keys))
     706             (old-method (when (%gf-methods gf)
     707                           (ignore-errors
     708                             (find-method gf qualifiers specializers nil)))))
     709
     710        (%add-method gf method)
     711        (when (and doc-p *save-doc-strings*)
     712          (set-documentation method t documentation))
     713        (record-source-file method 'method)
     714        (when old-method (%move-method-encapsulations-maybe old-method method))
     715        method))))
    711716       
    712717
     
    10121017;;; 2) the index of the first non-T specializer
    10131018(defun multi-method-index (method &aux (i 0) index)
    1014   (dolist (s (%method-specializers method) (values nil index))
     1019  (dolist (s (%method.specializers method) (values nil index))
    10151020    (unless (eq s *t-class*)
    10161021      (unless index (setq index i))
Note: See TracChangeset for help on using the changeset viewer.