When two proc have the same name, how can I get the proc address?
proc p2(x: int) =
echo x
proc p2(x: string) =
echo x
let t1 = p2 # ????????
Find a way, the following code seems fine.
proc p2(x: int) =
echo x
proc p2(x: string) =
echo x
let t1: proc(x: int) {.nimcall.} = p2
let t2: proc(x: string) {.nimcall.} = p2
t1(10)
t2("string")
echo toHex(cast[int](t1))
echo toHex(cast[int](t2))
Use a type conversion to disambiguate (I doubt that's documented well...)
(proc (x: string) {.nimcall.})(p2)
Yes, it can!!
I had tried this way:
cast[proc (x: string) {.nimcall.}](p2)
It doesn't work.