Created
September 11, 2018 23:40
-
-
Save exelotl/03c23322c4237b873a68f018516dfaae to your computer and use it in GitHub Desktop.
using type conversion syntax to choose the desired version of an overloaded function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc foo(x:int) = echo "int ", x | |
proc foo(x:string) = echo "string ", x | |
var p1:pointer = (proc(x:int){.nimcall.})(foo) # p1 gets the int version of foo | |
var p2:pointer = (proc(x:string){.nimcall.})(foo) # p2 gets the string version of foo | |
var f1 = cast[proc(x:int){.nimcall.}](p1) | |
var f2 = cast[proc(x:string){.nimcall.}](p2) | |
f1(100) | |
f2("boo") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment