Created
March 14, 2026 20:14
-
-
Save crazymonkyyy/a90053aa9799e395a3ba7a1ceb2c3518 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import std; | |
| import core.stdc.stdlib; | |
| import core.sys.posix.dlfcn; | |
| void printdelegate(string link){ | |
| auto f=cast(int function(int delegate(ref string)))dlsym(null,link.toStringz); | |
| foreach(e;toDelegate(f)){ | |
| e.writeln; | |
| }} | |
| unittest{ | |
| printdelegate("foo"); | |
| printdelegate("bar"); | |
| } | |
| extern(C): | |
| int foo(int delegate(ref string) f){ | |
| string s="a"; | |
| f(s); | |
| s="b"; | |
| f(s); | |
| return 0; | |
| } | |
| int bar(int delegate(ref string) f){ | |
| string s="APPLE"; | |
| f(s); | |
| s="BANANA"; | |
| f(s); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment