[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Clarification in 'luaL_optlstring' doc.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 13 Nov 2015 10:38:15 -0200
> >> I'd suggest to add to 'luaL_optlstring's doc something like:
> >> "If l is not NULL, fills the position *l with the result's length *** or 0 if the result is NULL *** ."
> > Do you need that?
> Not actually, though it seemed a sensible behavior to rely on. But after Nagaev's post I realised it is not the only sensible thing to do. So it does make sense to leave the contents of 'sz' undefined for the NULL case. So, sorry for the noise.
Leaving the length undefined may be sensible, but it is not what Lua
does right now :-) My question was really to know whether the current
behavior (which sets length to zero) is useful/being used.
In Lua, unlike in C standard libraries, there are several places where
NULL is identified with an empty array/block/string. For instance, we
recently modified 'lua_puhslstring' and 'luaL_addlstring' to safely
accept 'lua_pushlstring(L, NULL, 0)'. 'lua_Alloc' follows a similar
convention. So, it seems reasonable to expect a zero length for a