lua-users home
lua-l archive

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


perhaps...

function Pack(...)
    return arg
end

......

RetTable = Pack(pcall(Test, unpack(Param))

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Florian Berger
Sent: Thursday, October 16, 2003 2:51 AM
To: Lua list
Subject: Function pcall and 0..n return values



Hi.

I'm having following problem with function pcall. I'm using function pcall
with different functions that have their parameters (0..n) in a table. I
found unpack-function very practical for parameters. The problem is that
functions may also return 0..n return values. How could I code a general
case that saves return values of pcall-fucntion for example in a table? I
cannot use unpack-function for table as second return value because it
causes a syntax error.

Example for using unpack-function for parameters in a table:
function Test(a, b)
  return a, b
end

local bStatus, a, b
local Param = {1, 2}

bStatus, a, b = pcall(Test, unpack(Param))
print(a, b)


Floru