lua-users home
lua-l archive

Re: Little fun with vararg

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


> I don't know. This
> 
> 	x = 5
> 	function F(...)
> 	 return F(x,...)
> 	end
> 
> 	print(F())
> 
> is taking an awful long time to fail.
I believe this is O(n^2), as each new call copies all accumulated
arguments. Change your function to this and you will see the
slowdown:
local x = 0
function F(...)
 x = x + 1
 print(x)
 return F(x,...)
end
print(F())
(The stack limit is 100 000...)
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /