CodeSource
This package provides two macros: @code_src and @code_simple. Both macros display the source code for the method that will be dispatched based on the evaluated types of the function arguments. The only difference between the two is that @code_src output uses syntax highlighting while @code_simple output is plain text.
See examples below:
julia
using CodeSource
@code_src sum(1:10)function sum(r::AbstractRange{<:Real})
l = length(r)
# note that a little care is required to avoid overflow in l*(l-1)/2
return l * first(r) + (iseven(l) ? (step(r) * (l-1)) * (l>>1)
: (step(r) * l) * ((l-1)>>1))
endjulia
@code_simple sum(1:10)function sum(r::AbstractRange{<:Real})
l = length(r)
# note that a little care is required to avoid overflow in l*(l-1)/2
return l * first(r) + (iseven(l) ? (step(r) * (l-1)) * (l>>1)
: (step(r) * l) * ((l-1)>>1))
end