clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
vlaaad 2019-10-18T09:48:45.013500Z

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

alexmiller 2019-10-18T12:49:57.014200Z

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

vlaaad 2019-10-18T13:16:00.017Z

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.

bronsa 2019-10-18T13:16:23.017200Z

you can name the defmethod

vlaaad 2019-10-18T13:16:33.017400Z

how?

bronsa 2019-10-18T13:17:25.018100Z

user=> (defmulti foo identity)
#'user/foo
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).

vlaaad 2019-10-18T13:17:27.018200Z

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

vlaaad 2019-10-18T13:19:41.019600Z

your error does not have foo in output

bronsa 2019-10-18T13:20:05.019800Z

it has foo-one

bronsa 2019-10-18T13:20:11.020Z

you can name it on a per method basis

vlaaad 2019-10-18T13:20:27.020500Z

I want to know the multifn itself, not their component

vlaaad 2019-10-18T13:21:59.021900Z

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?

alexmiller 2019-10-18T13:23:08.022700Z

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

bronsa 2019-10-18T13:23:13.022900Z

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

vlaaad 2019-10-18T13:23:35.023200Z

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

alexmiller 2019-10-18T13:24:36.023500Z

https://clojure.atlassian.net/browse/CLJ-2419 looks similar

alexmiller 2019-10-18T13:24:58.023700Z

that's probably the closest one I can see

alexmiller 2019-10-18T13:25:56.024400Z

I added your comment above to that ticket

💯 1
vlaaad 2019-10-18T13:27:10.024600Z

thanks!

alexmiller 2019-10-18T13:27:31.024800Z

tweaked the title too

👍 1