[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Behaviour of unpack in 5.1alpha
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 20 Oct 2005 09:48:11 -0200
> Anyway, I think it is a problem with the luaL_* API,
> and possibly the lua_tonumber API as well. Although
> "bulkier", the following is more useful:
> [...]
A simpler solution for that particular kind of problem would be to
define luaL_opt* as macros:
#define luaL_optinteger(L,n,d) \
(lua_isnoneornil(L, (n)) ? (d) : luaL_checkinteger(L, (n)))
With them, we could simply change unpack to this:
e = luaL_optint(L, 3, luaL_getn(L, 1));
The only drawback is that the macro evaluates n twice...
-- Roberto