lua-users home
lua-l archive

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


> Like I said you only handled one of the two possible interpretations of
> 'boolean' in lua, the true/false only case. The other is the way lua
> treats things in an if ... then statement where anything other than false
> or nil is 'true'. Your code doesn't handle that second interpretation,
> because lua_isboolean checks the type of the value. So, for similar
> reasons to why there isn't a default table copy I would assume that they
> left it up to the person who wanted the check to write it there way.
> 
> But I am of course open to being corrected by the people who actually
> know.

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.

-- Roberto