title: Is there any way to programmatically determine in C/C++ how many parameters a Lua function expects?
body: <p>Is there a way to determine how many parameters a Lua function takes just before calling it from C/C++ code?</p>
  
  <p>I looked at <code>lua_Debug</code> and <code>lua_getinfo</code> but they don't appear to provide what I need.</p>
  
  <p>It may seem a bit like I am going against the spirit of Lua but I really want to bullet proof the interface that I have between Lua and C++.  When a C++ function is called from Lua code the interface verifies that Lua has supplied the correct number of arguments and the type of each argument is correct.  If a problem is found with the arguments a <code>lua_error</code> is issued.</p>
  
  <p>I'd like to have similar error checking the other way around.  When C++ calls a Lua function it should at least check that the Lua function doesn't declare more parameters than are necessary.</p>