-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LispWorks 8: c2mop:compute-applicable-methods-using-classes's default method specializes wrong class #21
Comments
According to the CLOS MOP specification, the primary method for compute-applicable-methods-using-class is specialized on standard-generic-function, not generic-function. See https://franz.com/support/documentation/10.1/doc/mop/dictionary.html#compute-applicable-methods-using-classes |
How about defaulting to (c2mop:defclass C () ())
(c2mop:defmethod M ((I C)))
(c2cl:compute-applicable-methods #'M (list (c2cl:class-prototype (find-class 'C))))
→ (#<standard-method m nil (c) 801025DE43>)
(c2cl:compute-applicable-methods-using-classes #'M (list (find-class 'C)))
>>>error: No applicable methods for #<lisp:standard-generic-function compute-applicable-methods-using-classes 826081B6E9> with args IMHO most of |
The CLOS MOP imposes a number of restrictions what portable programs can and cannot do. Adding methods to predefined metaobject classes is generally not a good idea. It might work in this particular case, but it might not work in others, and it's better to be consistent. The defaults for defclass and defgeneric are chosen so that if you don't choose and explicit :metaclass or :generic-function-class, you get something that primarily performs well, which means falling back to the built-in metaobject classes. The CLOS MOP is primarily designed for defining your own metaobject classes, and then you have to use :metaclass and :generic-function-class anyway. You can also :use :closer-common-lisp, and then CLOS-related symbols are taken from c2mop instead of cl. I know that invoking compute-applicable-method-using-classes is inconvenient if you don't have your own metaobject classes defined, but that's actually not its main purpose anyway. The main purpose is to change how applicable methods are determined for your own generic function metaobject class. Can't you just use compute-applicable-methods? What's your use case? |
Thank you for your explaining design choices about closer-mop. |
On lispworks8,
c2mop:compute-applicable-methods-using-classes
specializes onc2mop:standard-generic-function
.On other platform like SBCL, it specializes on
cl:generic-function
.on lispworks8
→
((c2mop:standard-generic-function t))
on sbcl
→
((cl:generic-function t))
IMHO (c2mop:compute-applicable-methods-using-classes cl:generic-function) is more natural and portable like other platforms.
The text was updated successfully, but these errors were encountered: