lua-users home
lua-l archive

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

On Wed, 03 Feb 2010 01:08:48 +0200, Gavin Wraith <> wrote:

I have always found Peter Shook's "Unpack Tables by Name" patch
very convenient with Lua 5.1. You could simply write

  local x,y,z in t

in place of

   local x,y,z = t.x,t.y,t.z

In Lua 5.2 the syntax of Shook's patch would appear to clash
with that for lexical environments, because after "local x,y,z in t"
the keyword "do" is expected.

It doesn't, the patch consumes 'in' token in the "localstat" context.
So the only change you need is ambiguity checking, like now done with
chained function calls:

local x
in t
do f() end

should be ambiguous. See attached patch which is
modified to compile against work2, and to report ambiguity.

Attachment: unpack-patch.patch
Description: Binary data