Function with unlimited arguments

It has been quite a while since i have coded anything, and i saw in some patch notes somewhere that the process of passing unlimited arguments had been changed.

So can anyone post a quick example? It would be much appreciated.

I believe that was the change to varargs with LuaJit, but was removed.

Thanks for the fast reply, and damn me for not checking before posting.

Can a mod please lock the thread, thanks.

Wouldn’t something like this work?
[lua]local function test(…)
local args = {…};

test(“alpha”, “beta”, 123456)[/lua]

However, you shouldn’t use arg anyway. At some point, it will be gone, and it’s bad practice to use it.

This, however the change will not be the result of LuaJit, as it was previously.

Why is it bad practice?

It’s like using self.Entity (though not as bad, I’ll admit.)
It’s depreciated, and therefore shouldn’t be used.

local function test(…)
test(“alpha”, “beta”, 123456)

Works fine.

self.Entity is depreciated because self is now equal to self.Entity.

Why would you want to create a new table when you can just use an already existing one for the varargs? The only problem I see, though, is when using arg with pairs or PrintTable due to the “n” member.

Arg is depreciated because the people over at say it is, and have removed it from Lua5.2
If Garry upgrades to 5.2 when it comes out, or gets LuaJIT working again, then your scripts will break if you use it.
Therefore, it’s bad practice.

function lolums( … ) print( … ) end; print( ‘Hey’, ‘Hey Apple!’ )

… represents ALL the arguments inserted in that space. Its like this kinda :

function lolums2( tab ) print( unpack( tab ) ) end ; print( { ‘hey!’, ‘Hey Apple!’ } );

He knows how it works, he just wanted to know about a change that never happened.
As for “var” it might not be a part of lua anymore, but it’s a part of
glua, just as the c syntax garry added (! /**/ // etc) so it’s just a matter of opinion.

At least the command that keeps every single script on GMod running is still there then, eh?

I assume varargs could be used like this…I think…maybe not.

Actually never mind, I really prefer args over the new varargs, so thank God it’s not deprecated.