Changeset 10027


Ignore:
Timestamp:
Jul 14, 2008, 1:17:18 PM (11 years ago)
Author:
gb
Message:

Define *ERROR-ON-GF-CLASS-REDEFINITION*, which controls whether
ENSURE-GENERIC-FUNCTION-USING-CLASS of an existing GF CERRORs
(as it traditionally has) if a :GENERIC-FUNCTION-CLASS argument
specifies a different class.

Defaults to NIL (no CERROR), which doesn't seem to conform to
what the MOP spec says about this, but which some publicly available
code seems to expect. (This is subject to change; signaling an
error here isn't necessarily worse than not doing so, and it really,
really does seem to be what the MOP says; it's arguably better to
adhere to the MOP than to have to remember and explain discrepancies.)

File:
1 edited

Legend:

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

    r9917 r10027  
    14271427      (setf (fdefinition function-name) gf))))
    14281428
     1429(defparameter *error-on-gf-class-redefinition* nil
     1430  "The MOP spec requires ENSURE-GENERIC-FUNCTION-USING-CLASS of an
     1431   existing gf to signal an error if the :GENERIC-FUNCTION-CLASS
     1432   argument specifies a class other than the existing gf's class.
     1433   ANSI CL allows this kind of redefinition if the classes are
     1434   \"compatible\", but doesn't define what compatibility means
     1435   in this case.  When *ERROR-ON-GF-CLASS-REDEFINITION* is true,
     1436   a continuable error is signaled.
     1437
     1438   Historically, Clozure CL CERRORed, but didn't offer a useful
     1439   CHANGE-CLASS method that would change the GF's class")
     1440
    14291441(defmethod ensure-generic-function-using-class
    14301442    ((gf generic-function)
     
    14351447  (declare (dynamic-extent keys) (ignorable function-name))
    14361448  (multiple-value-bind (gf-class initargs)
    1437       (normalize-egf-keys keys gf)
     1449x      (normalize-egf-keys keys gf)
    14381450    (unless (eq gf-class (class-of gf))
    1439       (cerror (format nil "Change the class of ~s to ~s." gf gf-class)
    1440               "The class of the existing generic function ~s is not ~s"
    1441               gf gf-class)
     1451      (when *error-on-gf-class-redefinition*
     1452        (cerror (format nil "Change the class of ~s to ~s." gf gf-class)
     1453                "The class of the existing generic function ~s is not ~s"
     1454                gf gf-class))
    14421455      (change-class gf gf-class))
    14431456    (apply #'reinitialize-instance gf initargs)))
Note: See TracChangeset for help on using the changeset viewer.