2008-12-21 01:03:48 |
Nikodemus Siivola |
description |
(reported by Bruno Haible)
ANSI CL is silent on this, but the MOP's specification of ENSURE-GENERIC-FUNCTION says:
"The remaining arguments are the complete set of keyword arguments
received by ENSURE-GENERIC-FUNCTION."
and the spec of ENSURE-GENERIC-FUNCTION-USING-CLASS:
":GENERIC-FUNCTION-CLASS - a class metaobject or a class name. If it is not
supplied, it defaults to the class named STANDARD-GENERIC-FUNCTION."
This is not the case in SBCL. Test case:
(defclass my-generic-function (standard-generic-function)
()
(:metaclass sb-pcl:funcallable-standard-class))
(setf (fdefinition 'foo1)
(make-instance 'my-generic-function :name 'foo1))
(ensure-generic-function 'foo1
:generic-function-class (find-class 'standard-generic-function))
(class-of #'foo1)
; => #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
(setf (fdefinition 'foo2)
(make-instance 'my-generic-function :name 'foo2))
(ensure-generic-function 'foo2)
(class-of #'foo2)
Expected: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
Got: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS MY-GENERIC-FUNCTION> |
(reported by Bruno Haible)
ANSI CL is silent on this, but the MOP's specification of ENSURE-GENERIC-FUNCTION says:
"The remaining arguments are the complete set of keyword arguments
received by ENSURE-GENERIC-FUNCTION."
and the spec of ENSURE-GENERIC-FUNCTION-USING-CLASS:
":GENERIC-FUNCTION-CLASS - a class metaobject or a class name. If it is not
supplied, it defaults to the class named STANDARD-GENERIC-FUNCTION."
This is not the case in SBCL. Test case:
(defclass my-generic-function (standard-generic-function)
()
(:metaclass sb-pcl:funcallable-standard-class))
(setf (fdefinition 'foo1)
(make-instance 'my-generic-function :name 'foo1))
(ensure-generic-function 'foo1
:generic-function-class (find-class 'standard-generic-function))
(class-of #'foo1)
; => #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
(setf (fdefinition 'foo2)
(make-instance 'my-generic-function :name 'foo2))
(ensure-generic-function 'foo2)
(class-of #'foo2)
Expected: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
Got: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS MY-GENERIC-FUNCTION>
As of 1.0.23 this test case behaves a bit differently, getting instead
Cannot CHANGE-CLASS objects into GENERIC-FUNCTION metaobjects.
[Condition of type SB-PCL::METAOBJECT-INITIALIZATION-VIOLATION]
See also:
The Art of the Metaobject Protocol, GENERIC-FUNCTION [:initialization]
on both ENSURE-GENERIC-FUNCTION calls. Need to figure out if this is righ, and if it is, if it
is possible to still provoke the original problem.
provoke a sim |
|