lua-users home
lua-l archive

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

Thanks guys for raising this very flammable subject that is table as list and holes, etc...
Once again few where able to divert the subject :).
I love Lua table approach and it's well defined # operator (that was for the troll part).

That said I was very interested in the first question: why the returned values of called function are trimmed to one value, unless it is the last one. I mean: I would like to understand the rational behind it.

If the answer is 'limit weird behavior' then it appears that it might seem that this trimming is also considered weird by some.
I would think that trimming is actually redundant with the () operator that does the job as well.

Would not it be plainer to actually not trim the extra returned values unless asked for it with the () operator ?

(1) t = { getvalues(), "some", "other", "values"}
would be different from
(2) t = { (getvalues()), "some", "other", "values"}

(1) would not trim returned values of getvalues() function, (2) would do it as specified by the embracing ().

Note: changing that would be a major incompatibility and would certainly break a lot of existing code. Not sure is this is easily catchable before hand...