Search code examples
dartoperator-keywordoperator-precedence

Change Dart's operator precedence


Is it possible to change the default operator precedence values in dart? I would like the precedence ordering of +, -, *, /, ^ to be consistent with mathematical notation with bitwise XOR representing power (+, -, *, and / are appropriately ordered, but ^ is lower than all of these).

In other words, is it possible to change precedences such that the following statements are equivalent:

a + b ^ c = a + (b ^ c),

for a, b, c of an appropriate class with relevant operators overriden.

(Precedence values given at very bottom of https://www.dartlang.org/docs/spec/latest/dart-language-specification.html#h.sn1uuf2ffwwd)


Solution

  • It is not possible to manipulate the operator precedence.

    Experience with quite a few other programming languages tells that this is almost never possible in a programming language.