For reflection purposes, I’m curious if there’s a way to get the current method? Something like:
function f(x)
get_current_method() # would return the f(x) Method
end
function f(x,y)
get_current_method() # would return the f(x,y) Method
end
Honestly it seems like a long-shot this would exist, but figured I’d ask just in case, or maybe I’ll learn something from someone explaining why this can never exist in Julia
julia> get_current_method() = stacktrace()[2].linfo.def
get_current_method (generic function with 1 method)
julia> function f(x)
get_current_method()
end
f (generic function with 1 method)
julia> function f(x,y)
get_current_method()
end
f (generic function with 2 methods)
julia> f(1)
f(x) in Main at REPL[2]:2
julia> f(1,2)
f(x, y) in Main at REPL[3]:2