Created
November 17, 2019 18:17
-
-
Save dhonx/619a28a67d1fc26a6b17e587f973fb69 to your computer and use it in GitHub Desktop.
Store function on array - V Programming Language
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
struct Sintf { | |
func fn() int | |
} | |
// Helper for calling the function | |
fn callf(p voidptr) int { | |
f := Sintf{ p }.func | |
return f() | |
} | |
fn main() { | |
afuncs := [ voidptr(test1), voidptr(test2), voidptr(test3) ] | |
for f in afuncs { | |
res := callf(f) | |
println(res) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment