lua-users home
lua-l archive

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

  for _, record in ipairs (database) do
      local name, email, address in record -- attributes
      process (name, email, address)
   end -- for

Just for the record -- I did eventually figure out how to put together a complete implementation of the extended table unpack syntax that Gavin proposed a couple years ago:

So, for example, in my own parser, this works:

  for _, record in ipairs (database) do
    process(name, email, address in record)

"record" can be replaced by any arbitrary _expression_, meaning that one can write things like:

  process(name, email, address in parse_record(line) )

After living with the patch for a few months though -- I'm not yet convinced it's worth the complication.  As Gavin says -- the form that one almost always ends up using is just the standard transformation:

  local a, b, c in t

Still, if anyone wants the more general patch, let me know, and I'll post a diff.