methodical icon indicating copy to clipboard operation
methodical copied to clipboard

Add no-applicable-method that gets called if there's no matching primary method

Open camsaul opened this issue 4 years ago • 4 comments

CLOS has this.

The default could just throw an Exception about there not being an impl like it does anyway. But maybe there's a use-case for customizing this behavior.

camsaul avatar Jun 11 '21 18:06 camsaul

I guess this might just have to be a plain old Clojure multimethod since it would be a low-level thing relative to the rest of Methodical. Not sure what is should dispatch off of... the multimethod var? How does this information get to the place where we dispatch? What happens for programmatically-defined methods? Maybe this should actually just be part of the options passed to defmulti (etc.) and then pass those along when we build the :dispatcher

camsaul avatar Jun 11 '21 18:06 camsaul

I'm not really 100% sure why I wipe her this issue and how this is really different from just writing a :default method. I'll have to try to remember.

camsaul avatar Sep 09 '22 14:09 camsaul

http://www.lispworks.com/documentation/HyperSpec/Body/f_no_app.htm

camsaul avatar Sep 09 '22 16:09 camsaul

I guess the only possible difference here instead vs writing a :default method would be that it wouldn't be visible as a next-method to anyone else. So this could be useful if you wanted to have some sort of more specific error message if there is no matching method than the default.

This differs a bit from what CLOS uses it for. According to CLOS-ERROR-CHECKING-ORDER

It was clearly intended that the call to no-applicable-methods be for value, rather than for effect. It just wasn't actually specified that way anywhere.

It seems like :default fits the "call for value" usage. So the main use case here would probably be for effect.

camsaul avatar Sep 09 '22 16:09 camsaul