chickadee » srfi-105 » mixed-operator-precedence


Defines the order of operations, or operator precedence, for supported operations. This should be a list of lists of symbols, each specifying a precedence group, ordered from highest to lowest precedence. Symbols are grouped with left-associativity by default. Instead of a symbol, (#:right symbol) can be used instead, indicating that symbol is an operator with right associativity.

If the first element of a group is the keyword #:comparison, the following members of that group should be treated as comparison operators that return a boolean, and are grouped as non-associative operators with and. For example, the group (#:comparison < >) implies that {1 > 3 < 4} will be grouped as (and (1 > 3) (3 > 4))

The special group (#:other) is a placeholder for any operators not present in (mixed-operator-precedence). These are grouped with left associativity. The parameter should contain at least this group, and is properly guarded as such.

The default roughly matches python's operator precedence:

'(((right: expt) (right: **))
  (* / modulo % quotient remainder
     fx* fx/ fxmod fxrem
     fp* fp/)
  (+ - fx+ fx- fp+ fp-)
  (arithmetic-shift << >> fxshl fxshr)
  (bitwise-and & fxand)
  (bitwise-xor ^ fxxor)
  (bitwise-ior ior fxior)
  (comparison: < <= > >= =
               fx< fx<= fx> fx>= fx=
               fp< fp<= fp> fp>= fp=)