lua-users home
lua-l archive

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


On Thu, Apr 10, 2014 at 2:38 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> Given f() that returns multiple values, is t[f()] intended to access
> all those values? Because then we have the classic
> propagation-of-multiple-values problem that gave you such grief with
> string.gsub.


I'd say yes, just like g(f()), where g() gets all return values from
f().  if you want just the first, you have to do g((f())).
specifically, if f() returns 1,2,3:

t[f()] => t[1,2,3]      -- like g(f())
t[(f())] = t[1]         -- like g((f()))
t[f(),4] => t[1,4]        -- like g(f(),4)
t[5,f()] => f[5,1,2,3]         -- like g(4,f())
t[f(),f()] => t[1,1,2,3]         -- like g(f(),f())


-- 
Javier