lua-users home
lua-l archive

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


On 20/01/2011 16.37, Thierry Van Elsuwe wrote:
Here is a small code where I've got an unexpected behavior
> (tried with Lua 5.1.4):

I get similar results with 5.1.2 (Windows):

  print (1 and true)
  --> true

  print (1 and true or false)
  --> true

  print ((1 or 2) and true)
  --> true

  print ((1 or 2) and true or false)
  --> 1

Maybe it's just afternoon drowsiness, but I'm a bit puzzled too. It's as if the inner set of parenthesis were ignored and the last one is interpreted as (1 or (2 and true) or false) due to precedence.

--
  Enrico