lua-users home
lua-l archive

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


Dimitris Papavasiliou <dpapavas@gmail.com> writes:
>> ... except for the last value: if require 'q' returns multiple values,
>> they'll all be put into the table.
>
> Incidentally, is there a practical reason for this exception?  I mean why
> not insert all returned values irrespective of the position within the
> initialization list?

[This has gotten lots of discussion on this list in the past.]

Such behavior is consistent with the treatment of multiple-values in
function argument lists -- and in the latter case it's important for
robustness (of user programs, not Lua itself):  functions in Lua can
return varying numbers of values (and it's not uncommon for functions
to return "extra" values that are often ignored), and whereas extra
return values at the end can be safely ignored, and so are basically
harmless, extra unexpected return values in the _middle_ are much more
likely to cause problems.

-miles

-- 
Friendship, n. A ship big enough to carry two in fair weather, but only one
in foul.