[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.pack/unpack (was: Lua 5.2 Length Operator)
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 17 Apr 2012 02:53:05 -0400
On Tue, Apr 17, 2012 at 2:46 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>> If table.pack were to always produce a sequence such that
>>> table.pack(1,2,3,nil,5) returned {1,2,3,5} then the table.* api set unifies and
>>> the ambiguity goes away.
>>>
>>> table.pack() explanation would read as - Packs all given arguments into a
>>> sequence, discarding nil values. This would keep in line with Section 2.1 of
>>> the manual, and the rest of the table.* api. Obviously, that would change this
>>> particular api's use case.
>>>
>
> You can see quite clearly why table.pack behaves as it does from this:
> The only difference between
>
> args = table.pack(...)
>
> and
>
> args = {...}
>
> is that in the first case args.n is set.
>
> In fact, table.pack is the standard library function one can most easily do
> without and it's amazing that it has not been deprecated yet.
Uh... it was just added in 5.2.
--
- Patrick Donnelly