Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Docs by
arglist:

bq. (defmethod multifn dispatch-val & fn-tail)

docstring:

bq. Creates and installs a new method of multimethod associated with dispatch-value.

There are a few issues with this docstring that make it hard to understand:

1. The {{& fn-tail}} argument is not documented. What is the type / shape of {{& fn-tail}}. I don't see any mention in the reference guide either - https://clojure.org/reference/multimethods
2. The docstring and arglists conflict about the name {{multimethod}} vs. {{multifn}}.
3. The docstring and arglists conflict about the name {{dispatch-value}} vs. {{dispatch-val}}.

Aside: on clojuredocs.org there is a mention of an optional name being allows on the method https://clojuredocs.org/clojure.core/defmethod#example-542692c7c026201cdc3269cd but I don't see that documented anywhere official. I'm not sure if it supported.

8 Answers

0 votes
by

Comment made by: alexmiller

fn-tail here means "additional args as could be passed to fn", which does include the function name, so that is supported.

0 votes
by

Comment made by: marc

Adding patch

0 votes
by

Comment made by: alexmiller

Rather than changing the docstring from multimethod to multifn, I would change the code from multifn to multimethod. Otherwise looks good.

0 votes
by

Comment made by: marc

Adding updated patch that changes the argument name to match the docstring, rather than the other way around.

0 votes
by

Comment made by: alexmiller

I'd prefer only the docstring to change here for the dispatch-val (so docstring changing to match the code).

0 votes
by

Comment made by: marc

Patch that changes only the docstring.

I've not changed the word {{multimethod}} to {{multifn}} in the docstring. I believe that even though the parameter is not documented, the name {{multimethod}} is more clear.

Can you elaborate on why you want to change the docstring rather than the argument name please Alex?

0 votes
by

Comment made by: alexmiller

I changed my mind and I think it would be better to just change the docstring to match the arg names.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2212 (reported by marc)
...