[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to "check" for a boolean function argument through the C api
- From: Etan Reisner <deryni@...>
- Date: Fri, 27 Jul 2007 17:01:36 -0400
On Fri, Jul 27, 2007 at 04:55:34PM -0400, Ralph Hempel wrote:
> RJP Computing wrote:
> >How do you "check" for a boolean argument from the C api? For that
> >matter, I want the argument to have a default value of 'false'. I see
> >that there are a bunch of luaL_checkxxx() functions, but none for
> >boolean. There is also the set of luaL_optxxx() functions and boolean is
> >not there either.
> Ryan, I could not find it in the C API either, so I wrote my own
> versions based on how the other versions that check for int, string, etc
> Then I figured there must be a good reason why that seemingly obvious
> API call is not included and decided to use 0 and non-zero integers
> Can anyone explain why these are not in the API?
Both lua_toboolean and lua_isboolean exist and can be used to do what you
I have no real idea why there is no luaL_checkboolean other than to guess
that perhaps (like table copying) there wasn't a clear ability to decide
what it should do exactly. Since both true/false only and the lua
normative definition of true/false are valid.