compound filter

A compound filter is a sequence of zero or more constituent filters enclosed in braces. The individual constituent filters are separated by white-space.
    compound-filter := '{' constituent-filters '}'
    constituent-filters := filter*
A compound filter is true in a position if all of its constituent filters are true in the position. For example,
    {check Ra3}
is a compound filter with two constituent filters: check and Ra3. It is true in a position if one side is in check and if a white Rook is on a3 in that position.

compound filter as a set filter

If a compound filter has a single constituent filter that is also a set filter then the compound filter is also a set filter. The compound filter's associated set in a position is the associated set of its single constituent filter in that position:
    {Ra3} = Ra3

short circuit evaluation

Whenever a filter in a compound filter is false in a position, later filters are not evaluated. For example,
    {Kh2
    check
    }
has two filters, but the check filter will be evaluated only if the first filter matches the position, i.e., if the King is on h2.

use of compound filters

Compound filters are mainly used in two situations. First, they control argument evaluation. For example,
    not Ra3 or Bb5
is a single not filter with argument Ra3 or Bb5. It is true whenever there is no R on a3 or B on b5. If we want to write
    {not Ra3} or Bb5
for positions in which either there is no R on a3 or there is a B on b5, then we need to use braces, i.e. the compound filter.

Braces are often used this way with transforms, since transform filters take a single argument but it is common to want to apply them to multiple arguments.

The second reason, clarity, is also illustrated by this example. Sometimes in CQL long strings of filters are chained together, particularly in long argument lists such as in a next filter. Rather than checking the operator precedence and parsing rules for CQL, it is much better just to enclose things in braces for clarity. There is never any performance penalty for this and it can make code clearer.

Examples