Hacker News new | ask | show | jobs
by xiaodai 2175 days ago
The problem with multiple dispatch is that by looking at

`fn(a, b, c)`

you really don't know which code it is running unless you know the types of `a`, `b`, and `c` which can't be exhaustively enumerated at the point of the writing the code or reading the code given that someone could use `fn` with totally different types.

This makes Julia readable, but as the code base grows, it can become unwieldly as well.

You really need `@which fn(a,b,c)` with known `a`, `b`, and `c` to see which function it is running.

2 comments

Isn't this a problem in any system that allows function names to be overloaded? Don't you have the same issues if (a) your system has single dispatch and classes that can be extended outside the module in which they're originally defined?
I agree and would say that normally dispatch comes in handy for things like `+`, `length` and of course your own functions where the meaning is the same but the implementation must be different depending on the type.
It exists! `@which fn(a,b,c)` will do exactly that. There's also `@less fn(a,b,c)` if you want to take quick look at the source code for the relevant method, or `@edit fn(a,b,c)` to open the relevant source file in an editor.