lua-users home
lua-l archive

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

On Feb 22, 2006, at 8:18 PM, Chris wrote:

On 2/22/06, Gavin Kistner <> wrote:
  I have no idea about how the internals of Lua work. Could someone
who does provide a really rough idea of how hard it would be to
extend the vararg syntax to work with:
      local a, b, ... = func(  )

local results = { func() }

not do what you want?  From there you can pick through results and grab "a" / results[1], "b" / results[2], ... and the rest

Not directly, no. Yes, I can grab 'a', and 'b' directly, but I can't use the (unknown) number of later values unless I shift the table down.

local results = { func() }
local a = table.remove( results, 1 )
local b = table.remove( results, 1 )
return 'x', unpack( results )

I had been assuming that I should avoid doing this. I thought that shifting the entire table down was relatively slow. Does Lua perform some nice internal magic on the internal array half of the table, just shifting the start pointer up?