Go to the first, previous, next, last section, table of contents.

Precedence

Different operators are generally assigned different precedences. By default, an operator defined by a rule like

# foo # := foo(#1,#2)

will have an extremely low precedence, so that `2*3+4 foo 5 == 6' will be parsed as `(2*3+4) foo (5 == 6)'. To change the precedence of an operator, use the notation `#/p' in place of `#', where p is an integer precedence level. For example, 185 lies between the precedences for `+' and `*', so if we change this rule to

#/185 foo #/186 := foo(#1,#2)

then `2+3 foo 4*5' will be parsed as `2+(3 foo (4*5))'. Also, because we've given the righthand expression slightly higher precedence, our new operator will be left-associative: `1 foo 2 foo 3' will be parsed as `(1 foo 2) foo 3'. By raising the precedence of the lefthand expression instead, we can create a right-associative operator.

See section Composition Basics, for a table of precedences of the standard Calc operators. For the precedences of operators in other language modes, look in the Calc source file `calc-lang.el'.


Go to the first, previous, next, last section, table of contents.