|
On 2018-02-11 11:55 AM, albertmcchan wrote:
does comma operator always process from left to right ? is it in the manual ? items = 0 function count(...) items = items + select(''#', ...) return items end = count(1,2,3), items 3 3 = count(1,2,3), items 6 6 = items, count(1,2,3) 6 9 = items, count(1,2,3) 9 12
I don't think Lua specifies argument evaluation order, either. I can't find anything in the manual. Lua makes no guarantees about the execution of expressions, only statements.
(Aka x(y(), z()) is UB)The only guarantee it seems to make is "Both `and` and `or` use short-circuit evaluation; that is, the second operand is evaluated only if necessary.":
http://www.lua.org/manual/5.3/manual.html#3.4.5 -- Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.