Operators

This the list of operators in Haxe, grouped by ascending precedence (i.e. descending priority) and with their associativeness :

  • ++, -- and unary - right-assoc
  • % left-assoc
  • * and / left-assoc
  • + and - left-assoc
  • <<, >> and >>> left-assoc
  • |, &, ^ left-assoc
  • ==, !=, >, >=, <, <= left-assoc
  • ... left-assoc
  • && left-assoc
  • || left-assoc
  • ?: right-assoc
  • =, +=, -=, /=, *=, <<=, >>=, >>>=, |=, &= and ^= right-assoc

Differences with other languages

Most other languages which have similar syntax are using the same operator precedence as in C (Java, PHP, JavaScript, etc).

Haxe precedence differ from these languages for the following cases :

  • % have lower precedence than * and / whereas in C these three have the same
  • |, & and ^ have the same precedence in Haxe, so they will be always grouped from left-to-right, whereas in C & have lower precedence than ^ which itself have lower precedence than |
  • |, & and ^ also have lower precedence than == and != in Haxe

Haxe compiler is ensuring that Haxe precedence is correctly enforced by adding the missing parentheses, for example when generating Javascript source.

version #16034, modified 2013-02-23 06:31:59 by shohei909