Note: information on this page refers to Ceylon 1.1, not to the current release.

Specification statements

The specification statement is used to define the value of a reference or the implementation of a getter or function.


A specification statement for a reference uses the = assignment symbol:

T t;
t = ... /* some expression of type T */

A specification statement for a getter of function uses the => fat arrow symbol:

T f(Float float);
f(Float float) => ... /* some expression of type T */

The same syntax may be used within a value or function declaration, but in this case it is not, strictly speaking, a specification statement:

T t = ... /* some expression of type T */
T f(Float float) => ... /* some expression of type T */


Note that => syntax consistently implies lazy evaluation, and = implies eager evaluation.

There is, in principle, an ambiguity between the assignment operator (the = operator) and the specification statement (the = statement). The specification says that the ambiguity is always resolved in favour of interpreting the statement as a specification statement. In practice, the only real semantic difference between these constructs is how they affect definite specifiction analysis.

Definite specification

The Ceylon typechecker ensures that references are definitely specified before they are used. Unlike in Java, references are never automatically initialized to zero or the null value.

These checks can be disabled using the late annotation.

See also