lua - Order of evaluation with mixed logical and relational operators? -



lua - Order of evaluation with mixed logical and relational operators? -

what lua interpreting poorly formed look as?

return 1 or 2 == 3 , 4 -> 1

it's not stepping through each operator left right:

return (1 or 2) == 3 , 4 -> false

is evaluating in reverse?

you might used arithmetic operators having different precedences. example, if write 1 + 2 * 3 assumed multiplication comes before add-on in 1 + (2 * 3) instead of evaluating left right in (1 + 2) * 3. these standard math precedences used in programming languages. notable counterexamples can think of smalltalk, evaluates left-to-right , languages forcefulness explicit precedence (lisp , forth).

as relational , boolean operators, customary programming languages extend traditional arithmetic precedences cover operators in language. lua's total precedence table can found here:

http://www.lua.org/manual/5.2/manual.html#3.4.7

or , < > <= >= ~= == .. + - * / % not # - (unary) ^

the boolean and , or operators have lowest precedences 1 or 2 == 3 , 4 parsed 1 or ((2 == 3) , 4).

lua order-of-evaluation

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -