Keywords
Keywords are reserved tokens whose role in the language is defined in the language specification. They may not be used as identifiers.
Usage
Usage depends on the keyword in question.
Description
The following are reserved keywords:
-
abstracts
(currently unused) alias
-
assembly
(currently unused) assert
assign
break
case
catch
class
continue
dynamic
-
else
(used with thefor
,if
andswitch
statements, in theif
expression and as an operator) -
exists
(used withif
and as an operator) -
extends
used in class declarations to specify the superclass and invoke superclass initializers, and also in constructor declarations to invoke superclass constructors. finally
for
function
given
-
if
used for theif
statement and theif
expression import
-
in
(used for variance and with thefor
statement and as an operator) interface
-
is
(used in theif
,while
, andcase
statements and as an operator) let
module
new
-
nonempty
(used in theif
,while
, andcase
statements and as an operator) object
-
of
(used withclass
andinterface
declarations) and as an operator) out
outer
package
return
-
satisfies
(used inclass
andinterface
declarations) super
-
switch
is used for theswitch
statement and theswitch
expression -
then
is used inif
expressions and also as thethen
operator this
throw
try
value
void
while
Quoting
It is possible to quote keywords, creating an identifier from a character
sequence which would otherwise be treated as keyword by the lexer. For example
\iout
creates an identifier called out
. The intended purpose of quoting is
interoperation with other languages. For example, it may be necessary to invoke
or refine a method named out
on a class written in Java (where out
is not a
keyword).
Annotations
Other identifiers commonly seen in declarations (such as shared
) are not
keywords but annotations.
See also
- Identifiers and keywords in the Ceylon specification