How Precedence is determined
The precedence of any new notation or operator is determined by examining the components from which it is constructed. For instance, is grouped according to the precedence of +, the operator is grouped according to the precedence of , and the mapping is grouped according to the precedence of . Generally the grouping behavior of positioning boxes is determined by the "base element". For instance, the expression SubscriptBox[symb, sub] is grouped according to symb. But for some other structural boxes the grouping behavior of surrounding elements is not affected by the behavior of the contents of the box. The precedence of compound objects is determined according to the following table
The standard boxes and their relationship to precedence.
The design decision of making the precedence of new compound operators correspond to their constituents makes intuitive sense and generally leads to notations that are consistent. For instance, consider a possible notation for addition and multiplication over a ring .
This defines a notation for ring addition and ring multiplication.
Mathematica now can parse and format expressions containing ring additions and multiplications.
The ring multiplication operator has a higher precedence than the ring addition operator because * has a higher precedence than + . Moreover, the notation is automatically set up to parenthesize the expression appropriately to maintain the correct structure.
The output has the correct formatting, styling, spacing, and parenthesization.
However the above notation for ring addition and ring multiplication is still somewhat limited.
The above Notation statement can be removed and an InfixNotation can be used instead.
Now and act as true infix operators for RingPlus and RingTimes.