lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> > I was just wondering why the aux library provides luaL_opt* 
> functions 
> > 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*
functions.

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
semantics.

- DC