lua-users home
lua-l archive

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


2014-08-30 9:20 GMT+02:00 Mike Nelson <mikestar1313@gmail.com>:

> Try http://lua-users.org/wiki/VarargTheSecondClassCitizen for a discussion
> of issues. This topic is about Lua 5.1, but nothing has changed in
> subsequent versions with regard to varargs except the addition of
> table.pack.

The contents list is:

Issue #1: Vararg Saving
Issue #2: Combining Lists
Issue #3: Selecting the First N Elements in List
Issue #4: Appending One Element to a List
Issue #5: Reversing a List
Issue #6: The map Function
Issue #7: The filter Function
Issue #8: Iterating over Varargs

75% of the space is devoted to eight dubious ways of achieving #1.

The pure Lua solutions to #3 to #7 are for Lua purists. They are
obviously easily solved by writing a little 'tuple' library using the
C API, and I am probably not alone in having done so
as an exercise at an early stage of learning the API.

The main lesson to be gleaned there is that the yearning to make
varargs do things they were not designed for, is older than the date
that most current high-volume contributors to this list started their
activity. I heartily agree with Mike's implication that anyone
who posts or comments on any query/suggestion dealing with
varargs would do well to read that webpage first.