[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaL_optboolean ?
- From: Mark Hamburg <mhamburg@...>
- Date: Wed, 12 Sep 2007 08:45:11 -0700
on 9/11/07 7:44 PM, Daniel Collins at dcplus@bigpond.com wrote:
> I was just wondering why the aux library provides luaL_opt* functions
> for integers, numbers and strings but not for booleans. It is not a big
> deal since I just define my own as
> int luaL_optboolean (lua_State *L, int narg, int def)
> {
> return lua_isboolean(L, narg) ? lua_toboolean(L, narg) :
> def;
> }
>
> I am just curious about why some types were chosen for the opt functions
> and some were not.
That doesn't actually have the right semantics for the opt functions.
I believe the standard semantics are:
* None or nil returns default
* Incorrect type throws an error
* Correct type returns that value
Mark