Fork me on GitHub
#clojure-dev
<
2019-10-18
>
vlaaad09:10:45

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

alexmiller12:10:57

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

vlaaad13:10:00

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 \"[email protected]\"]" I know this is clojure.core/inc. This is not the case for MultiFns, since they are displayed as "#object[clojure.lang.MultiFn 0x250a946 \"[email protected]\"]" without any hint to what they are about.

bronsa13:10:23

you can name the defmethod

bronsa13:10:25

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

vlaaad13:10:27

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

vlaaad13:10:41

your error does not have foo in output

bronsa13:10:05

it has foo-one

bronsa13:10:11

you can name it on a per method basis

vlaaad13:10:27

I want to know the multifn itself, not their component

vlaaad13:10:59

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?

alexmiller13:10:08

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

bronsa13:10:13

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

vlaaad13:10:35

should I request it on http://ask.clojure.org?

alexmiller13:10:58

that's probably the closest one I can see

alexmiller13:10:56

I added your comment above to that ticket

💯 1
alexmiller13:10:31

tweaked the title too

👍 1