[Feature] why not a `functionswith` method?

Something like this might do the trick:

julia> functionswith(T) = unique(fieldtype(method.sig, 1).instance for method in methodswith(T))
functionswith (generic function with 1 method)

julia> functionswith(Int)
67-element Array{Function,1}:
 middle (generic function with 6 methods)
 clear! (generic function with 7 methods)
 serialize (generic function with 53 methods)
 rem (generic function with 139 methods)
 & (generic function with 16 methods)
...

There’s a few corner cases where this will error but maybe it’s a useful starting point.

FWIW, the corner cases are a good illustration why it’s hard to create something like your request. Consider the following definition:

julia> (::Val{N})(x::NTuple{N}) where N = N

julia> Val(3)((4,5,6))
3

This gives us a method that’s not associated to a well-defined function, because there’s a where clause over both the function and the argument:

julia> @which Val(3)((4,5,6))
(::Val{N})(x::Tuple{Vararg{T,N}} where T) where N in Main at REPL[12]:1

julia> (@which Val(3)((4,5,6))).sig
Tuple{Val{N},Tuple{Vararg{T,N}} where T} where N

This illustrates why methodswith is in Base but not functionswith. Does that help?

3 Likes