When calling a function, the function itself is treated like a 2nd class citizen.
That is, the function is fixed and the dispatch system only considers the other arguments.
However, when broadcasting the function is treated on par with the other arguments.
[1,2] .+ [3,4] # becomes Base.broadcast(.:+, [1,2], [3,4])
I propose a method dispatch mechanism that first dispatches to a function that can be overloaded, much like the
getproperty function has been introduced to overload calls to
invoke is already taken. Maybe the function name
call would be suitable.
The ability to define functions like
Base.call(f, x::MyNumberType, args...) or
Base.call(f, A::MyCollection, args...)
could make it a lot easier to wrap numbers or collections with a new type.
Currently one may have to define over a hundred new methods just to wrap number types.
See package AbstractNumbers for an example.
With the proposed mechanims one could accommodate many functions with only a handfull of “call” overload methods, one for each method signature.
I am aware of Proposal for a first-class dispatch wrapper but that involves a much more complicated mechanism.