Dynamic Binding

This library supports dynamic binding (the c# dynamic keyword). This allows for simpler code and easier reading. The types LuaMethod, LuaTable, and LuaEnvironment all support dynamic binding. To use this, simply set a dynamic object to an instance of one of these types.

If you access a member or indexer for LuaTable, it will look for the value with the specified key (case sensitive). If you do it on LuaEnvironment, it will look for the global variable with the specified name. If you call a LuaMethod or LuaChunk, it will invoke the object.



dynamic d = lua.Environment;

// call a global function

// get a global variable
int v = d.Value;

// get and call a LuaMethod object
dynamic method = d.Life;
method(12, "foo");


Note that any numerical arguments are converted to doubles so two numbers with the same value will be the same index even if they are of different types.  It is suggested to ignore any member of the above types that start with 'Try' (e.g. 'TryGetMember') these methods are not meant to be called by user code.

Last edited May 26, 2013 at 2:29 AM by ModMaker, version 2


No comments yet.