[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (rc2) now available
- From: Daurnimator <quae@...>
- Date: Sun, 27 Nov 2011 13:14:45 +1100
On 27 November 2011 00:52, Roberto Ierusalimschy <firstname.lastname@example.org> wrote:
>> My proposal  was that table.pack should set __len metamethod
>> instead of returning the value or setting "n" field.
>> Wouldn't it be less risky ?
>>  http://lua-users.org/lists/lua-l/2011-06/msg01386.html
> It is more tricky. We think that 'n' should be something explicit.
> (But we may remove the extra return, as it is redundant with the 'n'
> -- Roberto
I'd much rather you didn't set n.
Often you need the args in a list; and the length of the list (eg, to iterate)
local t , n = table.pack(...)
for i=1 , n do
without the 2nd return value you have to do [[for i=1,t.n do]] which
just seems strange.
As the code: table.unpack(table.pack(...)) is useless; I don't think
it is valuable to retain symmetry.