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

import statement

The import statement is used to express a dependency on a type defined in another package. All import statements for a compilation unit must occur in a list at the top of the file.

Note: This page is not about module import statements occurring in a module descriptor.


The import statement has several variations:

// importing a list of declarations
import math { sqrt, pi, Complex }

// importing all declarations in a package
// (a 'wildcard' import)
import com.example.metasyntax { ... }

// assigning a different name to an imported declaration
// (an 'alias' import)
import org.example.metasyntax { ExampleFoo=Foo, Bar }

// assigning a different name to a member of an imported type
import org.example.metasyntax { Foo { b=bar } }


Since Ceylon does not support the use of fully-qualified names in code, name conflicts between declarations imported from different packages must be resolved by assigning a unique name to at least one of the declaration in the import statement. This new name is called an import alias.


Use of wildcard imports (e.g. import com.example.metasyntax { ... }) is discouraged, since:

  • when reading, it makes it harder to determine which package a particular type name in the source code is referring to, and
  • as the declarations in imported packages change over time, there's the possibility of name collisions, even though none existed at the time the code was written.

See also

  • Imports in the Ceylon language specification