Skip to content

Instantly share code, notes, and snippets.

@JesseKPhillips
Created October 11, 2011 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JesseKPhillips/1278488 to your computer and use it in GitHub Desktop.
Save JesseKPhillips/1278488 to your computer and use it in GitHub Desktop.
This will cause the assert on line 184 of functions.d to fire.
version(Windows) {
pragma(lib, "lua51.lib");
} else
pragma(lib, "liblua.a");
import std.stdio;
import luad.all;
alias string delegate(string) MyFun;
void main() {
auto lua = new LuaState();
lua.openLibs();
MyFun[string] funs;
void makeCall(string name, string str) {
funs[name](str);
}
void addFun(string name, MyFun fun) {
funs[name] = fun;
}
lua["makeCall"] = &makeCall;
lua["addFun"] = &addFun;
lua.doString(q{
function echo(str)
return str
end
addFun("echo", echo)
makeCall("echo", "hello")
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment