Caching of effective methods in custom method combinations
Pascal Costanza
pc at p-cos.net
Tue Jul 21 10:16:56 UTC 2015
> On 21 Jul 2015, at 10:30, Didier Verna <didier at lrde.epita.fr> wrote:
>
> Edi Weitz wrote:
>
>> Hi everybody,
>>
>> Here's some behavior I see on SBCL as well as LispWorks, so I'm
>> assuming for now they're right in doing so. My question would be why
>> they are.
>
> Hi Edi,
>
> you may want to read this:
> http://www.didierverna.net/blog/index.php?post/2013/08/16/Lisp-Corner-Cases%3A-Method-Combinations
find-method-combination doesn’t exist for end users to retrieve method combination objects, but it exist for ensure-generic-function to retrieve it. (Same for find-class by the way: The primary purpose for find-class is so that ensure-class can find the class object. That it needs fewer arguments than find-method-combination is just incidental.)
find-method-combination accept the generic function metaobject as a parameter because that’s just how the MOP generally works: You use class metaobjects or generic function metaobjects to hang your hat on and provide your own user-defined extensions. find-method-combination additionally accepts the method combination parameters so it can return optimized method combination objects, for example to distinguish between short form / long form, or predefined (like standard) or user-defined ones. For example, a user-defined method combination may recognize that for some parameters, it behaves the same as a standard one, etc.
Method combinations are generally neglected in AMOP and only minimally specified. My guess, after reading about the history of the CLOS MOP, is that the AMOP authors thought of method combinations to be redundant and not really needed, which is actually true once you have user-defined generic functions metaobject classes, because you can do pretty much anything with the latter that you can also do with the former. Method combinations are in Common Lisp probably because at the time they were added, the AMOP was not in a usable shape yet, and there was already experience with method combinations that made them useful especially in the absence of a MOP.
I still think there is good reason to use method combinations because they are more reliably supported across CL implementations, but if you feel like you have to push them too hard, it’s probably better to switch to user-defined generic function classes.
Pascal
--
Pascal Costanza
The views expressed in this email are my own, and not those of my employer.
More information about the pro
mailing list