|
Roberto wrote:
That depends on how you do the testing. You can try a lot of loops (where each one creates its own closure), with each loop very short (so it does not dilute that cost) ;-). Something like local t = {1,2} for i=1,2^20 do local s=0 for k in list(t) do s=s+k end end
I'm not sure what you're saying. Both your test and my original one show list and ipair as having the same time performance.
It is arbitrary, but it covers the two most typical cases (pairs & ipairs). Of course closures give a more general solution, but for those typical cases <<var_1 + "table">> do the job and avoids garbage creation.
Besides being arbitrary, it's more confusing than closures. Is avoiding the garbage there going to have any effect on a real program?
-- http:// i . /