doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
doSomething(arg1, arg2, arg3, arg4)
or
local function doSomething(tbl)
– Do something with the parameter
end
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
doSomething({arg1, arg2, arg3, arg4})
If both of them are optimized the same way, then I guess it’s a matter of taste. But I think the 2nd way is a bit easier to read.
There’s no difference in the way Lua will handle it.
When the function is called, the arguments are put on the stack, the function is compiled and the local variables are instantiated and initialized.
This means that the function is called only once, no matter how many arguments you pass.
The only difference is that in the second case, you have to unpack the table and put the arguments in local variables.