lua-users home
lua-l archive

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


What should we expect from this code?

x = 1
function f()
  x = x + 1
  return x
end

a,b,a = f(), f(), f()
print(a,b,x)

I checked a bit the Lua 5.0.2 manual and there is no clarification,
except for the fact that f() is called 3 times.

The result of the execution is 2,3,4.
I think there are 2 possibilities:
- after the f() calculation assignments are performed from the right
  to the left
- assignments are performed from the left to the right but there is a 
  check for duplicate variable name

I guess the first.

In any case... isn't this a good place to generate an error? Is this
check considered too heavy or not so interesting?

thanks
-- 
Enrico Tassi