lua-users home
lua-l archive

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


On Thu, Aug 13, 2009 at 5:09 PM, Peter Cawley<lua@corsix.org> wrote:
> Should now be fixed.

Yes, indeed. I am slightly humbled by how quickly someone picked this
up and ran with it!

Not really a bug, but I did notice a minor inconsistency (if you're
busy, I wouldn't bother updating the patch for it):

> function multivalues()  return 1,2,3;  end
> print( unpack{multivalues()...} )
1       2       3
> print( multivalues()... )
stdin:1: Cannot expand last expression in a list, as it is already
expanded near ')'

In the "array elements" context it ignores ... on the final element,
while in the "expression list" context, it throws an error. In my
opinion, both cases should ignore it - that seems more Lua-ish, a bit
like ignoring the final comma/semicolon in a table constructor.

However, I feel the opposite way about a very similar inconsistency:

> print( unpack{"a"..., "b"} )
a       b
> print( "a"..., "b" )
stdin:1: Cannot expand fixed-length expression near '"b"'

It seems correct to me to always throw an error when someone tries to
expand what is known to be a fixed-length expression.

-Duncan