lua-users home
lua-l archive

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


> It seems to me that using all the return values would be what one would 
> expect. Discarding values in this one situation seems inconsistent. 
> Why the special case?

We would say that the normal case is to keep only one value, and the 
special case is to allow multiple values when the function is the last (or 
the only) one in a list ;-) In Lua, the same function may return different 
number of values; so, it would be very difficult to understand something 
like 

  a,b,c = f(), g()

if f() can (dynamically) return 1 or 2 values.


> Does it make Lua's implementation easier?

Yes.

> Are there idioms where this is genuinely useful?

Not that I know. But if you think that the special case is when Lua keeps
multiple returns, then for sure there are many useful idioms (for instance 
«assert(readfrom"name")») 


> Any chance this will change in future versions?

Anything might change in the future, but we are happy with the current
semantics.


-- Roberto