**Table of Contents**

- 16.1. Generator Expressions and Sequential Evaluation
- 16.2. Method Invocation Expressions
- 16.3. Primary Expressions
- 16.4. Query Expressions
- 16.5. Bracket Access Expressions
- 16.6. Array Generator Expressions
- 16.7. Instance Scope Expressions
- 16.8. Exponentiation Operator
- 16.9. Containment Operator
- 16.10. Guard Operator
- 16.11. Range Operator
- 16.12. Expression Lists

The *expressions* of the XL programming language
are a superset of the expressions of the Java programming language. For
the general terms and specifications in the context of expressions
and their evaluation,
see the Java language specification. Based on these definitions,
this chapter describes the
expressions which are introduced by the XL programming language.

To simplify the formulations, the following convention is implicitly
present in the following, if not specified otherwise: If a subexpression
* s* which is part of an expression

`e`

`e`

`e`

`s`

When an expression in a programme is *evaluated*,
the result denotes one of three things: A variable (in the C programming
language, this would be called an *lvalue*),
a value, or nothing (the expression is said
to be `void`

). This holds
for the normal evaluation of expressions and is the same as for
the Java programming language.

The XL programming language defines
*generator expressions* which successively
*yield* results.
These expressions cannot be evaluated normally,
they have to be evaluated *sequentially* by
special language constructs, namely the enhanced
`for`

statement, aggregate method invocation expressions,
expression statements, the `yield`

statement,
or expression predicates. A sequential evaluation of a normal or
generator expression
* e* yields several results in succession and
is performed in the following way:

Let

, ...,`s`

_{1}be the subexpressions of`s`

_{n}in their evaluation order, i.e., from left to right.`e`

is evaluated sequentially by a recursive application of this definition. For each yielded result`s`

_{1},`v`

_{1}is evaluated sequentially yielding results`s`

_{2}and so on, finally leading to a sequential evaluation of`v`

_{2}.`s`

_{n}For each yielded result

, the expression`v`

_{n}is evaluated in a special context: When`e`

evaluates its subexpressions`e`

, these are treated as being constant expressions having the previously computed values`s`

_{k}. If`v`

_{k}is a normal expression, this special evaluation of`e`

is done normally, and the single result is yielded as a result of the sequential evaluation of`e`

. Otherwise,`e`

is a generator expression. Then the special evaluation is done sequentially as defined for the specific generator expression, and each yielded result is yielded as a result of the whole sequential evaluation.`e`

A generator expression is called a
*sequential expression*.
The following definitions and specifications apply to sequential expressions:
Let * s* be a sequential expression.

If

is a subexpression of a containment expression or an aggregate method invocation expression, then this containing expression is called the`s`

*target*of.`s`

Otherwise, if

is a subexpression of an expression`s`

not covered by the previous definition,`e`

is also called a sequential expression, and the target of`e`

is defined to be the target of`s`

. It is a compile-time error if`e`

is a conditional operator (`e`

`||`

,`&&`

, or`?:`

) or a compound assignment operator andis not the first (left-most) operand.`s`

Otherwise, if

is the expression of a`s`

`yield`

statement or an expression statement, this statement is the target of.`s`

Otherwise, if

is the iterator expression of an enhanced`s`

`for`

statement, the`for`

statement is the target of.`s`

In any other case, a compile-time error occurs.