lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>> 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.