lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Jul 19, 2006 at 11:39:03AM -0400, Jerome Vuarand wrote:
> From: Jerome Vuarand <>
> Your existing function (that you named "function" but I'll call it "foo" for clarity) :
> 	void c_foo(int x, int y, data_t* p); // I assume the value pointed by p is an in/out parameter since you want to modify it

As another approach, you might consider wrapping c_foo() into a function
with a return value. Lua functions can have multiple return values,
unlike C, so you don't have to return values through output pointers:

  int c_values(int x, int y, struct Foo** output);

  could be

  -- status is int, output is userdata wrapping a "struct Foo*"
  status, output = lua_c_values(5, 6);