How to see all overriden types or functions of Base?


#1

I wonder if there is a way to all types or functions in Base that have been overridden after using a package. I did some careful search, but no useful hits. Thanks for any comments.


#2

If by “override” you mean “redefine for the same signature”, this is considered bad form unless there is a compelling reason to do so.

If you just want the methods defined in a module, then methodswith takes a module argument.

julia> using ValidatedNumerics
julia> methodswith(Any, ValidatedNumerics)
5-element Array{Method,1}:
 ..(a, b) at /home/tamas/.julia/v0.5/ValidatedNumerics/src/intervals/intervals.jl:60                                         
 interval_from_midpoint_radius(midpoint, radius) at /home/tamas/.julia/v0.5/ValidatedNumerics/src/intervals/arithmetic.jl:371
 isempty(itr) at iterator.jl:3                                                                                               
 setindex(a::FixedSizeArrays.FixedArray, value, index::Int64...) at /home/tamas/.julia/v0.5/FixedSizeArrays/src/indexing.jl:8
 ±(a, b) at /home/tamas/.julia/v0.5/ValidatedNumerics/src/intervals/intervals.jl:66                                          

#3

Thanks. You’re right. I shouldn’t have used the word “override”. I meant the new methods added to a Base function. methods() or methodswith() are both of great use. But I wonder if there is a way to list all new methods added to functions in Base by a package. Maybe there isn’t such a command.


#4

It is possible that I do not understand your requirement, but methodswith(Any, module) will list all methods defined by that module.

You can filter the result by checking which of those is defined in Base, eg with isdefined:

function all_redefinitions(_module, _in_module=Base)
    m = methodswith(Any, _module)
    filter(m->isdefined(_in_module, m.name), m)
end

#5

No. You understood correctly. I confused myself. I thought with Any being the first argument, the methods defined by Base are also returned. I totally forgot the optional second argument. Thanks a lot!