[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Catching and passing multiple values
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 23 Feb 2006 10:05:12 -0800
What's needed is a pack/unpack pair that does the right counting.
(The following is untested.)
function npack( ... )
local result = { ... }
result.n = select( '#', ... )
return result
end
local nunpack( t )
return unpack( t, 1, t.n )
end
If you do this a lot, you probably want to create C versions because you can
decrease the number of times the parameter list is copied.
All that being said, it's too bad that xpcall doesn't take its parameters
as:
xpcall( handler, fn, ... )
That would have resolved this problem without the need to pack up the
arguments though the code still wouldn't be pretty.
Mark