Is it possible to get a reference to proc by its symbol for multi-dispatch proc?
I need to auto-generate some code based on function signature, and can't get the reference to the function.
run (seems like it's not showing output in the online playground)
import macros
macro generate_some_code*(fn: typed): typed =
echo fn.tree_repr
proc multiply*(a: float, b: float): float = generate_some_code(multiply)
proc multiply*(a: string, b: string): string = generate_some_code(multiply)
discard multiply(1.0, 1.0)
discard multiply("A", "x")
Output:
Sym "multiply"
ClosedSymChoice
Sym "multiply"
Sym "multiply"
It has reference to the self in the first case, but not in the other. How to get the reference to self in the second case?