[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua "..." args
- From: David Jeske <jeske@...>
- Date: Wed, 17 Dec 1997 23:56:27 -0800
On Wed, Dec 17, 1997 at 09:54:38PM -0200, Steve Dekorte wrote:
> It would be nice if, when I have a method using variable args, I
> could pass those args along to another function with the "..." syntax.
> Example:
uhm... pass them along with call();
> function SomeObject:myMethod(blah, ...)
> return anotherObject:anotherMethod(...)
> end
How about just
function SomeObject:myMethod(blah, ...)
-- do something to shift all the args down one to make room at
-- args[1];
args[1] = anotherObject.anotherMethod; -- set "self" for the call()
return call(anotherObject.anotherMethod,args);
end
> Instead of the uglier and more limited way:
>
> function SomeObject:myMethod(blah, ...)
> local argCount = tableLength(arg)
>
> if ( argCount == 0 ) then
> return anotherObject:anotherMethod(forwardMethod)
> end
> if ( argCount == 1 ) then
> return anotherObject:anotherMethod(forwardMethod, arg[1])
> end
> if ( argCount == 2 ) then
> return anotherObject:anotherMethod(forwardMethod, arg[1], arg[2])
> end
> if ( argCount == 3 ) then
> return anotherObject:anotherMethod(forwardMethod, arg[1], arg[2], arg[3])
> end
> end
>
--
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net