The Ceylon Language

Say more, more clearly

Gavin King

Final release draft (1.1)


Table of Contents

Welcome to Ceylon
1. Introduction
1.1. Language overview
1.1.1. Runtime and platform
1.2. Type system
1.2.1. Mixin inheritance
1.2.2. Algebraic types, self types, and type families
1.2.3. Simplified generics
1.2.4. Union and intersection types
1.2.5. Type aliases and type inference
1.2.6. Metaprogramming
1.3. Object-oriented programming
1.3.1. Class initialization and instantiation
1.3.2. Functions, methods, values, and attributes
1.3.3. Defaulted parameters and variadic parameters
1.3.4. First-class functions and higher-order programming
1.3.5. Naming conventions, annotations, and inline documentation
1.3.6. Named arguments and tree-like structures
1.3.7. Modularity
1.4. Language module
1.4.1. Operators and operator polymorphism
1.4.2. Numeric and character types
1.4.3. Compile-time safety for optional values and type narrowing
1.4.4. Iterable objects and comprehensions
1.4.5. Sequences and tuples
2. Lexical structure
2.1. Whitespace
2.2. Comments
2.3. Identifiers and keywords
2.4. Literals
2.4.1. Numeric literals
2.4.2. Character literals
2.4.3. String literals
2.5. Operators and delimiters
3. Type system
3.1. Identifier naming
3.2. Types
3.2.1. Member distinctness
3.2.2. Subtyping
3.2.3. Union types
3.2.4. Intersection types
3.2.5. The bottom type
3.2.6. Principal typing
3.2.7. Type expressions
3.2.8. Type abbreviations
3.2.9. Type inference
3.2.10. Type alias elimination
3.3. Inheritance
3.3.1. Inheritance and subtyping
3.3.2. Extension
3.3.3. Satisfaction
3.4. Case enumeration and coverage
3.4.1. Coverage
3.4.2. Cases
3.4.3. Generic enumerated types
3.4.4. Disjoint types
3.5. Generic type parameters
3.5.1. Type parameters and variance
3.5.2. Variance validation
3.5.3. Generic type constraints
3.6. Generic type arguments
3.6.1. Type arguments and type constraints
3.6.2. Applied types and and variance
3.6.3. Type argument inference
3.7. Principal instantiations and polymorphism
3.7.1. Inherited instantiations
3.7.2. Principal instantiation inheritance
3.7.3. Principal instantiation of a supertype
3.7.4. Refinement
3.7.5. Qualified types
3.7.6. Realizations
4. Declarations
4.1. Compilation unit structure
4.1.1. Toplevel and nested declarations
4.1.2. Packages
4.2. Imports
4.2.1. Type imports
4.2.2. Function and value imports
4.2.3. Alias imports
4.2.4. Wildcard imports
4.2.5. Imported name
4.3. Parameters
4.3.1. Parameter lists
4.3.2. Required parameters
4.3.3. Defaulted parameters
4.3.4. Value parameters
4.3.5. Callable parameters
4.3.6. Variadic parameters
4.4. Interfaces
4.4.1. Interface bodies
4.4.2. Interface inheritance
4.4.3. Sealed interfaces
4.4.4. Interfaces with enumerated cases
4.4.5. Interface aliases
4.4.6. Dynamic interfaces
4.5. Classes
4.5.1. Callable type of a class
4.5.2. Initializer section
4.5.3. Declaration section
4.5.4. Class inheritance
4.5.5. Abstract, final, sealed, formal, and default classes
4.5.6. Member class refinement
4.5.7. Anonymous classes
4.5.8. Classes with enumerated cases
4.5.9. Class aliases
4.6. Type aliases
4.7. Functions
4.7.1. Callable type of a function
4.7.2. Functions with blocks
4.7.3. Functions with specifiers
4.7.4. Function return type inference
4.7.5. Forward declaration of functions
4.7.6. Functions with multiple parameter lists
4.7.7. Formal and default methods
4.7.8. Method refinement
4.8. Values
4.8.1. References
4.8.2. Getters
4.8.3. Setters
4.8.4. Value type inference
4.8.5. Forward declaration of values
4.8.6. Formal and default attributes
4.8.7. Attribute refinement
5. Statements, blocks, and control structures
5.1. Block structure and references
5.1.1. Declaration name uniqueness
5.1.2. Scope of a declaration
5.1.3. Visibility
5.1.4. Hidden declarations
5.1.5. References and block structure
5.1.6. Type inference and block structure
5.1.7. Unqualified reference resolution
5.1.8. Qualified reference resolution
5.2. Blocks and statements
5.2.1. Expression statements
5.2.2. Control directives
5.2.3. Specification statements
5.2.4. Definite return
5.2.5. Definite initialization
5.2.6. Definite uninitialization
5.3. Control structures and assertions
5.3.1. Control structure variables
5.3.2. Iteration variables
5.3.3. Control structure conditions
5.3.4. Boolean conditions
5.3.5. Assignability, existence, and nonemptiness conditions
5.3.6. if/else
5.3.7. switch/case/else
5.3.8. for/else
5.3.9. while
5.3.10. try/catch/finally
5.3.11. Assertions
5.3.12. Dynamic blocks
6. Expressions
6.1. Literal values
6.1.1. Integer number literals
6.1.2. Floating point number literals
6.1.3. Character literals
6.1.4. Character string literals
6.2. String templates
6.3. Self references and the current package reference
6.3.1. this
6.3.2. outer
6.3.3. super
6.3.4. package
6.4. Anonymous functions
6.4.1. Anonymous function parameter type inference
6.5. Compound expressions
6.5.1. Base expressions
6.5.2. Member expressions
6.5.3. Value references
6.5.4. Callable references
6.5.5. Static expressions
6.5.6. Static value references
6.5.7. Static callable references
6.6. Invocation expressions
6.6.1. Direct invocations
6.6.2. Default arguments
6.6.3. The type of a list of arguments
6.6.4. Listed arguments
6.6.5. Spread arguments
6.6.6. Comprehensions
6.6.7. Positional argument lists
6.6.8. Named argument lists
6.6.9. Anonymous arguments
6.6.10. Specified arguments
6.6.11. Inline declaration arguments
6.6.12. Iterable and tuple enumeration
6.6.13. Dynamic enumerations
6.7. Conditional expressions and anonymous class expressions
6.7.1. Inline conditional expressions
6.7.2. Let expressions
6.7.3. Inline anonymous class expressions
6.8. Operators
6.8.1. Operator precedence
6.8.2. Operator definition
6.8.3. Basic invocation and assignment operators
6.8.4. Equality and comparison operators
6.8.5. Logical operators
6.8.6. Operators for handling null values
6.8.7. Correspondence, subrange, and stream operators
6.8.8. Operators for creating objects
6.8.9. Conditional operators
6.8.10. Arithmetic operators
6.8.11. Set operators
6.9. Metamodel expressions
6.9.1. Type of a metamodel expression
6.10. Reference expressions
6.10.1. Declaration references
6.10.2. Package and module references
6.10.3. Type of a reference expression
7. Annotations
7.1. Annotations of program elements
7.1.1. Annotation lists
7.1.2. Annotation arguments
7.2. Annotation definition
7.2.1. Annotation constructors
7.2.2. Annotation types
7.2.3. Constrained annotation types
7.3. Annotation values
7.4. Language annotations
7.4.1. Declaration modifiers
7.4.2. Documentation
7.5. Serialization
8. Execution
8.1. Object instances, identity, and reference passing
8.1.1. Value type optimizations
8.1.2. Type argument reification
8.2. Sequential execution and closure
8.2.1. Frames
8.2.2. Current instances and current frames
8.2.3. Current instance of a class or interface
8.2.4. Current frame of a block
8.2.5. Initialization
8.2.6. Class instance optimization
8.2.7. Execution of expression and specification statements
8.2.8. Execution of control directives
8.2.9. Exception propagation
8.2.10. Initialization of toplevel references
8.2.11. Initialization of late references
8.3. Execution of control structures and assertions
8.3.1. Evaluation of condition lists
8.3.2. Validation of assertions
8.3.3. Execution of conditionals
8.3.4. Execution of loops
8.3.5. Exception handling
8.3.6. Dynamic type checking
8.4. Evaluation, invocation, and assignment
8.4.1. Dynamic dispatch
8.4.2. Evaluation
8.4.3. Assignment
8.4.4. Invocation
8.4.5. Evaluation of anonymous functions
8.4.6. Evaluation of enumerations
8.4.7. Evaluation of spread arguments and comprehensions
8.5. Operator expressions
8.5.1. Operator expression optimization
8.5.2. Numeric operations
8.6. Evaluation of comprehensions
8.6.1. for clause
8.6.2. if clause
8.6.3. Expression clause
8.7. Concurrency
9. Module system
9.1. The module runtime and module isolation
9.1.1. Module isolation for the Java platform
9.1.2. Module isolation for the JavaScript platform
9.1.3. Assemblies
9.2. Source layout
9.3. Module architecture
9.3.1. Module names and version identifiers
9.3.2. Module archive names for the Java platform
9.3.3. Module script names for the JavaScript platform
9.3.4. Source archive names
9.3.5. Documentation archive names
9.3.6. Module archives
9.3.7. Module scripts
9.3.8. Source archives
9.3.9. Documentation archives
9.3.10. Module repositories
9.3.11. Package descriptors
9.3.12. Module descriptors