lua-users home
lua-l archive

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


On Thu, Aug 13, 2009 at 1:19 PM, Peter Cawley<lua@corsix.org> wrote:
> On Thu, Aug 13, 2009 at 1:00 PM, steve donovan<steve.j.donovan@gmail.com> wrote:
>> Now, would this also apply to function argument lists, which is the
>> other place where multiple returns are not discarded if at the end?
>
> According to the BNF description of Lua, the arguments in a function
> call are an expression list, so IMO it should apply here too (and my
> patch does so).
>
> E:\CPP\2K8\lua-5.1.4-proto>Debug\lua-5.1.4-proto.exe
> Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>> t = {4, 5, 6}
>> print(unpack(t) ..., 7)
> 4       5       6       7
>> print(unpack{4, unpack{5, 6} ..., 7} ..., 8)
> 4       5       6       7       8
>
> Also note that attached is a revised patch.
>

Thanks again for this Peter, I've experimented with it a bit more and
found some bugs - both relating to trying the "Return duplicated
arguments" test with different numbers of arguments:
+ Zero arguments ends up with a single "nil" value (it looks like
detuple is expanding an empty list to one nil value?)
+ One argument ends up with some weird value that Lua represents as ":
0000000" instead (a tuple that never got detupled?)

I have only tried the revised patch, so I don't know if these are
present in the original one as well.

Cheers,
-Duncan