[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (rc2) now available
- From: HyperHacker <hyperhacker@...>
- Date: Sat, 26 Nov 2011 05:49:41 -0700
On Sat, Nov 26, 2011 at 05:16, Patrick Rapin <firstname.lastname@example.org> wrote:
> After looking a little bit more, this is not a bug but a pitfall.
> Function table.pack returns two values: a table and its length.
> When passing it directly to table.unpack, the second result is taken
> as the starting index.
> An extra parenthesis solves the problem.
> 1 2 3
> Still, is there a way to avoid that pitfall ?
> I will probably not be the last to try that apparently logical syntax...
> 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
n does seem a bit redundant when you have __len...
Sent from my toaster.