Lua

Simplifying Lua calls with C++0x variadic templates

Lua and C++ can interact through a stack with function parameters pushed onto the stack in the same way as is done in assembly. The stack interface is very effective but it can get annoying to keep pushing multiple arguments onto the stack to call functions with multiple parameters. This style of code can also be error prone – since most of the code is repetetive a programmer will start to copy and paste code and may forget to change a lua_pushboolean call to a lua_pushnumber call, which could lead to strange bugs. However, with the variadic templates added in the C++0x standard we can easily write a few functions around the lua calls that remedy this situation.

read more

C++0x, Lua

---