Giter Site home page Giter Site logo

Comments (4)

pcostanza avatar pcostanza commented on August 20, 2024

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

from closer-mop.

g000001 avatar g000001 commented on August 20, 2024

How about defaulting to cl:standard-generic-function rather than c2mop:standard-generic-function ?
Defaulting to c2mop:standard-generic-function is bit annoying because,
it causes unsynmetric behavior between compute-applicable-methods and compute-applicable-methods-using-classes (on LispWorks 8)

(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 c2mop:defgeneric or c2mop:defmethod usage is without explicit (:generic-function-class c2mop:standard-generic-function) option.
and c2mop:defgeneric sets implicit default to cl:standard-generic-function rather than c2mop's GF.

from closer-mop.

pcostanza avatar pcostanza commented on August 20, 2024

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?

from closer-mop.

g000001 avatar g000001 commented on August 20, 2024

Thank you for your explaining design choices about closer-mop.
I will just use compute-applicable-methods.
Much appreciated.

from closer-mop.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.