Type Modifiers

Type Declarations can sport a range of modifiers that affect how the member works or is accessed.

Type Modifiers are provided after the = that separates the type's name from the declaration itself, and before the remainder of the declaration.

type
  MyClass = public sealed Class
  end;
  
  Distance = public type Double;

The order of modifiers has no relevance, but note that combinations of modifiers that would be contradictory or non-sensible are not permitted.

Visibility Modifiers

Each type can be marked with an individual Visibility Level that controls where the type can be accessed. If no visibility level is specified, the default is assembly, marking the type as available everywhere within the project, but not externally.

  • unit — only accessible from within the same file
  • assembly — only accessible from within this project
  • public — accessible from everywhere

Please refer to the Member Visibility Level topic for a detailed description of visibility levels.

Example:

type
  MyClass = public Class
  end;

Other Modifiers

The following additional modifiers are supported for various types:

  • abstract — (Classes only) marks the class as being abstract. Abstract classes are considered "incomplete", and cannot be instantiated at runtime. Any class that contains abstract Members must be marked as such. Descendant classes must implement all abstract members in order to become able to be instantiated.
  • extension — (Classes and Records only) marks the type to be an Extension Type.
  • inline — (Arrays only) marks the array to be inlined within the stack space of a Record. See Inline Arrays for details.
  • parallel — (Sequences only) marks the sequence as parallel. See Parallel Sequences for details.
  • partial — (Classes and Records only) marks the type to be a Partial Type.
  • queryable — (Sequences only) marks the sequence as queryable. See Queryable Sequences.
  • readonly — (Classes and Records only) makes all fields in the class or record readonly.
  • sealed — (Classes only) marks the class as sealed, meaning that it will not be allowed to declare further descendants.
  • soft — (Interfaces only) marks an interface to be a Soft Interfaces for use with Duck Typing.
  • static — (Classes and Records only) marks the type as static. A static type cannot be instantiated at runtime. All Members declared within the type will automatically become static as well (whether explicitly marked as such with a Member Modifier or not).
  • type — (Type Aliases only) marks the new type alias as a distinct type and "incompatible" with the original type. Values of the original type cannot be assigned to variables of the new type, or vice versa, without explicit cast.

Type Suffixes

Not strictly type modifiers:

  • Mapped Classes or Records use the mapped to type suffix to indicate mapping to a different, existing type.
  • Nested Types use the nested in type suffix to indicate that the type is considered a member of another type.

See Also