[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.pack/unpack (was: Lua 5.2 Length Operator)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 17 Apr 2012 08:46:53 +0200
>> 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.