On Nov 26, 2011 7:15 PM, "Daurnimator" <firstname.lastname@example.org> wrote:
> On 27 November 2011 00:52, Roberto Ierusalimschy <email@example.com> 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'
> > field.)
> > -- 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)
If anything this discussion shows that no policy lua sets will be satisfactory for every use case. As I've said in the past, I would rather see lua adopt its philosophy of allowing the programmer set the policy: don't set 'n', return the length in the second return.