[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Lua 4.0
- From: "Ashley Fryer" <lua@...>
- Date: Fri, 25 Aug 2000 16:14:19 -0700
>When a C function is called, its parameters are on the stack.
>When it returns, the results are also on the stack. To separate them, the
>function returns (in C) the number of results it is returning (in
>Lua).
Why is it necessary for the C API to return the number of results it pushed
onto the stack? Wouldn?t it would be simpler and less error-prone for Lua
to infer that information directly from the stack?
IE, why can?t your example:
static int math_sin (lua_State *L) {
lua_pushnumber(L, sin(TORAD(luaL_check_number(L, 1))));
return 1; /* <<<< Tells Lua it is returning one result */
}
be written as:
static void math_sin (lua_State *L) {
lua_pushnumber(L, sin(TORAD(luaL_check_number(L, 1))));
}
It should be trivial for Lua to track the number of results pushed by the
API, yes?
ashley