From: Bruno H. <br...@cl...> - 2004-08-02 11:44:37
|
In SBCL 0.8.11, the function compute-default-initargs is expected to return a list of the form ((keyword function) ...), but according to the MOP it should return a list of the form ((keyword form function) ...). See MOP p. 39, description of compute-default-initargs "The value returned by this generic function is a list of canonicalized default initialization arguments." and MOP p. 16 "A canonicalized default initarg is a list of three elements. The first element is the name; the second is the actual form itself; and the third is a function of zero arguments which, when called, returns the result of evaluating the default value form its proper lexical environment." Here is a test case. If you change (list ':extra '*extra-value* #'(lambda () *extra-value*)) to (list ':extra #'(lambda () *extra-value*)) it works in SBCL. I.e. SBCL implements a different protocol. ;; Check that it's possible to add additional initargs. (progn (defparameter *extra-value* 'extra) (defclass custom-default-initargs-class (standard-class) ()) (defmethod sb-pcl:compute-default-initargs ((class custom-default-initargs-class)) (let ((original-default-initargs (remove-duplicates (reduce #'append (mapcar #'sb-pcl:class-direct-default-initargs (sb-pcl:class-precedence-list class))) :key #'car :from-end t))) (cons (list ':extra '*extra-value* #'(lambda () *extra-value*)) (remove ':extra original-default-initargs :key #'car)))) #-CLISP (defmethod sb-pcl:validate-superclass ((c1 custom-default-initargs-class) (c2 standard-class)) t) (defclass testclass10 () ((slot :initarg :extra)) (:metaclass custom-default-initargs-class)) (slot-value (make-instance 'testclass10) 'slot)) Expected: EXTRA Got: ERROR Bruno |