16.4. Query Expressions

A query expression is a generator expression yielding values which match a query pattern (Chapter 17, Queries). The type of a query expression is the type of the out-parameter of its compound predicate, or void if no out-parameter exists. The sequential evaluation of a query expression is performed by invoking the query as specified in Section 17.2, “Invocation of Queries”. For each match of the query, the value of the query variable associated with the out-parameter is yielded, or nothing if no out-parameter exists.

The scope of the query variables of the query's compound predicate is the rest of the target (Section 16.1, “Generator Expressions and Sequential Evaluation”) of the query expression, or the rest of the innermost expression list between the target and the query expression if such an expression list exists.