Chapter 16. Expressions

Table of Contents

16.1. Generator Expressions and Sequential Evaluation
16.2. Method Invocation Expressions
16.2.1. Argument Transformations
16.2.2. Generator Method Invocations
16.2.3. Aggregate Method Invocations
16.2.4. Filter Method Invocations
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 completes abruptly, then e completes abruptly for the same reason, and remaining subexpressions of e, if any, are not evaluated. The remaining subexpressions are the subexpressions to the right of s.

16.1. Generator Expressions and Sequential Evaluation

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 s1, ..., sn be the subexpressions of e in their evaluation order, i.e., from left to right.

  • s1 is evaluated sequentially by a recursive application of this definition. For each yielded result v1, s2 is evaluated sequentially yielding results v2 and so on, finally leading to a sequential evaluation of sn.

  • For each yielded result vn, the expression e is evaluated in a special context: When e evaluates its subexpressions sk, these are treated as being constant expressions having the previously computed values vk. If e 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.

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

  • If s is a subexpression of a containment expression or an aggregate method invocation expression, then this containing expression is called the target of s.

  • Otherwise, if s is a subexpression of an expression e not covered by the previous definition, e is also called a sequential expression, and the target of s is defined to be the target of e. It is a compile-time error if e is a conditional operator (||, &&, or ?:) or a compound assignment operator and s is not the first (left-most) operand.

  • Otherwise, if s is the expression of a yield statement or an expression statement, this statement is the target of s.

  • Otherwise, if s is the iterator expression of an enhanced for statement, the for statement is the target of s.

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