[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Heap usage and variable argument C functions
- From: Wim Couwenberg <wcou@...>
- Date: Tue, 21 Dec 2004 07:59:06 +0100
Vararg functions create a table for the ellipsis (stored in 'arg')
each time the function is called."
I am assuming this does not apply to C functions called from Lua.
You are right. All parameters are on the stack. Note that in Lua 5.1
this also holds for new style Lua vararg functions. Here is an example:
function f(...) print(arg) end
function g(...) print(...) end
function h(...) print(arg) print(...) end
f(1, 2, 3)
table: 007c7b74
g(1, 2, 3)
1 2 3
h(1, 2, 3)
nil
1 2 3
So the new ellipsis operator acts like a function that is implicitly
called and returns all arguments. For 5.0 compatibility, the arg table
is still created if a vararg function does not use ellipses in its body.
--
Wim