Enhance multimethods metadata


I think that multimethod metadata can be extended a bit with some property indicating the var in question is referring to a multimethod (we have something similar for macros) and some default arglists property.

I'm raising this issue because as a tool writer (CIDER) I'm having hard time determining if something is a multimethod (I have to resort to code like (instance? clojure.lang.MultiFn obj) which is acceptable, but not ideal I think (compared to macros and special forms)). There's also the problem that I cannot provide the users with eldoc (function signature) as it's not available in the metadata (this issue was raised on the mailing list as well https://groups.google.com/forum/#!topic/clojure/crje_RLTWdk).

I feel that we really have a problem with the missing arglist and we should solve it somehow. I'm not sure I'm suggesting the best solution and I'll certainly take any solution.




Cam Saul
September 21, 2019, 4:01 AM

Here’s a couple patches that add :arglists to multimethod metadata. The first one is a very simple patch that only works for dispatch functions that are def'ed somewhere:

This second patch is a little more sophisticated and handles inline fn declarations and keywords as well, so it should cover the majority of dispatch functions. But it is a little more complicated.

I included both patches in case the latter proves too controversial – even merging just the first would be a big win.

Let me know if either patch is headed in the right direction and I can add some tests as well

Bozhidar Batsov
September 9, 2014, 10:24 AM

Btw, I failed to mention this as I thought it was obvious, but I think we should use the dispatch function's arglist in the multimethod metadata.

Your pinned fields
Click on the next to a field label to start pinning.




Bozhidar Batsov






Affects versions