[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: luaL_optboolean ?
- From: "Daniel Collins" <dcplus@...>
- Date: Thu, 13 Sep 2007 11:34:01 +1000
> > I was just wondering why the aux library provides luaL_opt*
> > for integers, numbers and strings but not for booleans.
> Just use lua_toboolean() and write the code so that missing
> and false arguments do the same thing. This is the way to be
> most consistent with Lua's boolean semantics.
OK, I see the problem with optboolean now. Normally nil will equate to
false. However I want missing function parameters to get the default
value I supply in code. If I define my optboolean to return false for
nil then missing parameters will always be false. So the Lua semantics
for booleans don't really allow an optboolean function to work with the
"if the parameter is present and the correct type return it's value,
otherwise return the default I supply" approach of the other opt*
I will keep using the function I wrote because it does what I want even
though it is not strictly correct from the point of view of lua boolean