From The Elements Wiki
Jump to: navigation, search

This is an Oxygene Language topic

Oxygene Language: Intro | Structured Overview | Grammar | Keywords | Functions

Keywords, or reserved words, have a special meaning in the Oxygene language. Oxygene, with its Pascal background, is a very expressive and readable language that uses keywords where other languages (such as the C family, including C++, C#, Java and Objective-C) use more cryptic symbols. As such, Oxygene makes use of a rather wide range of keywords, and additional keywords may be introduced in future versions, as the language evolves.

Full Keywords

The following words act as keywords on a global scope and regardless of context:


Conditional Keywords

The following are only keywords in a particular context (e.g. has acts as a keyword within a where clause of a generic type only). The word array is only treated as a keyword when followed by of or by a square bracket ([]). In all other contexts, it may be used freely as an identifier (for example to refer to the System.Array type on .NET). The same applies to sequence.

Outside of their specific context, these words may be freely used as identifiers, although their use as such is discouraged to avoid conflicts later on if the identifier in question needs to be used in a conflicting context.


Conditional Keywords for Query Expressions

The following are only keywords in the context of Query Expressions:


Legacy Keywords

Create acts as a keyword, if, and only if, the compiler option for Legacy Create Constructors is enabled. Other legacy keywords that are ignored: cdecl, library, overload, packed, pascal, platform ,publsihed, reference, register, safecall, stdcall, strict.

Compiler Magic Functions

Although not keywords as such, Oxygene provides a list of so-called Compiler Magic Functions. Please refer to the respective topic for reference.

Escaping Keywords

By default, Keywords cannot be used as names for Identifiers. Sometimes Oxygene keywords conflict with existing types of members you want to use in your code (or even with names you decided to use yourself). Two commonly encountered examples on .NET are the "System.Type" and "System.Reflection.Assembly" types.

There are two ways to escape keywords and allow their use as identifiers:

  1. Identifiers can be prefixed with an ampersand, such as var lAssembly: &Assembly;. This ampersand will not be considered part of the name, it's just used to escape the use of the keyword.
  2. Keywords can be used as identifiers without explicit escaping, when following the period operator, such as: var lAssembly: System.Assembly;. The only exception is the Create keyword, if Legacy Create Constructors are enabled.