Fork me on GitHub

can I vote somewhere to make MultiFns more inspectable? Like making it's name field public so I can write my own print-method for them that gives me hint what that function is

Alex Miller (Clojure team)12:10:57

Can you back up to the problem you’re having and describe it?


The problem is I want to understand values at the repl. When I have fns in repl output, I can get some understanding of what values it refers to. For example, seeing "#object[clojure.core$inc 0x63bca84d \"clojure.core$inc@63bca84d\"]" I know this is clojure.core/inc. This is not the case for MultiFns, since they are displayed as "#object[clojure.lang.MultiFn 0x250a946 \"clojure.lang.MultiFn@250a946\"]" without any hint to what they are about.


you can name the defmethod


user=> (defmulti foo identity)
user=> (defmethod foo 1 foo-one [x] (throw (Exception. "")))
#object[clojure.lang.MultiFn 0x32c8e539 "clojure.lang.MultiFn@32c8e539"]
user=> (foo 1)
Execution error at user/eval140$foo-one (REPL:1).


I mean I know, I can make name field accessible using reflection and read it, but this feels brittle


your error does not have foo in output


it has foo-one


you can name it on a per method basis


I want to know the multifn itself, not their component


and I would prefer to see it when I print it, not in an exception it throws: do I have to guess args to pass it so it throws?

Alex Miller (Clojure team)13:10:08

there are some multimethod tickets out there, I'm not sure if this is one of them


right, I see -- maybe that's an enhancement request then, including the defmulti name in the multimethod toString


should I request it on

Alex Miller (Clojure team)13:10:58

that's probably the closest one I can see

Alex Miller (Clojure team)13:10:56

I added your comment above to that ticket

💯 4
Alex Miller (Clojure team)13:10:31

tweaked the title too

👍 4