lua-users home
lua-l archive

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


On 4 June 2014 11:55, Thiago L. <fakedme@gmail.com> wrote:
> That just drops the comma no? I think something like
> "print(somemultireturnfunc(),)" should do the same as
> "print((somemultireturnfunc()))" instead...

The presence of an extra comma would leave me second-guessing the
behavior on multiple returns too. In any case, it should do the same
as the table constructor. Went to check what the table constructor
does:

Lua 5.1.2  Copyright (C) 1994-2007 Lua.org, PUC-Rio
> function f() return 1, 2 end
> t = { f() }
> print(t[1], t[2])
1    2
> u = { f(), }
> print(u[1], u[2])
1    2
> v = { f(), 3 }
> print(v[1], v[2])
1    3
>

So, yes, if function calls were to accept a trailing comma, I think
they should just drop the comma and not impose special behavior on
multiple returns, for consistency with the table constructor.

-- Hisham