[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to "check" for a boolean function argument through the C api
- From: "RJP Computing" <rjpcomputing@...>
- Date: Fri, 27 Jul 2007 18:41:11 -0400
On 7/27/07, Roberto Ierusalimschy <firstname.lastname@example.org> wrote:
Your explanation is correct. lua.h provides low-level facilities that
try to allow maximum flexibility. lauxlib.h provides higher-level
facilities for some usual tasks; unlike lua.h, it does not try to be
"complete". Most functions that accept booleans behave (or should
behave?) like Lua: any value but nil/false is true, nil/false is
false. With this interpretation, we do not need a checkboolean, because
any value is valid.
OK just so I have this strait, I can use the luaL_checkany() function? I guess what I am driving at is the ability to use the parameter as a boolean like in C++. My problem is then I have to do the type conversion. If I use luaL_checkint() I have to cast the value. This doesn't seem as useful as adding the functionality to
luaxlib.h. Like you said it provides the higher level and it seems to miss boolean. On the same argument, if you are saying that you don't want to pidgin hole a boolean into a certain type, well the lua_isboolean() has already defined what a boolean should be. I am not trying to argue, just understand the motivation.