[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: strfind "bug"
- From: Peter Shook <peter.shook@...>
- Date: Sat, 22 Dec 2001 02:39:13 -0500
Edgar Toernig wrote:
>
> Peter Shook wrote:
> >
> > But with lua_settop you get a behavior that is the same as that of Lua
> > functions without changing the API. And how does the argument handling
> > function 'luaL_check_type' stop working in this example?
> >
> > static int luaB_eventtable (lua_State *L) {
> > luaL_check_type(L, 1, LUA_TTABLE);
> > if (lua_isnull(L, 2))
> > lua_geteventtable(L, 1);
> > else {
> > lua_settop(L, 2);
> > luaL_check_type(L, 2, LUA_TTABLE);
> > lua_seteventtable(L, 1);
> > }
> > return 1;
> > }
>
> This function does _not_ behave like a Lua function[1]: eventtable(x)
> gives a different result than eventtable(x,nil). You want lua_settop as
> the first statement of the function. luaL_check_type will then break if
> used with LUA_TNONE as would lua_isnull or all the luaL_opt_xxx functions.
>
> Ciao, ET.
>
> [1] unless you implement it with varargs (function eventable(x, ...))
> which would be counterintuitive.
Yes, that's true. But my question was supposed to be rhetorical with
the point being that if you don't change the code, and you only consider
the else part, then luaL_check_type still works even though lua_settop
was called previously.
I should have taken a different example from the Lua source where they
don't combined two functions into one.
Your proposal is fine, but what you suggest can be done with the current
API.
- Peter
- References:
- strfind "bug", rrthomasrr
- Re: strfind "bug", Edgar Toernig
- Re: strfind "bug", Reuben Thomas,,,690081
- Re: strfind "bug", Edgar Toernig
- Re: strfind "bug", Peter Shook
- Re: strfind "bug", Edgar Toernig
- Re: strfind "bug", Peter Shook
- Re: strfind "bug", Edgar Toernig