[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1.4 Type Declaration

A type declaration looks like this:

 
type
  type identifier = type definition;
  ...
  type identifier = type definition;
or, with preset content:
 
type
  type identifier = type definition value constant expression;
  ...
  type identifier = type definition value constant expression;

A type declaration part begins with the reserved word type. It declares a type identifier which is defined by type definition. A type definition either can be an array, a record, a schema, a set, an object, a subrange, an enumerated type, a pointer to another type identifier or simply another type identifier which is to alias. If a schema type is to be declared, type identifier is followed by a discriminant enclosed in parentheses:

 
type identifier (discriminant) = schema type definition;

If value is specified, followed by a constant satisfying the type definition, every variable of this type is initialized with constant expression, unless it is initialized by value itself. The reserved word value can be replaced by `=', however value is not allowed in ISO-Pascal and Borland Pascal, and the replacement by `=' is not allowed in Extended Pascal.

Type declaration example

 
type
  { This side is the }     { That side is the }
  { type declaration }     { type definition  }

Arrayfoo = array [0 .. 9] of Integer; { array definition } Recordfoo = record { record definition } Bar: Integer; end;

{ schema def with discriminants ``x, y: Integer'' } SchemaFoo (x, y: Integer) = array [x .. y] of Integer; CharSetFoo = set of Char; { Def of a set } ObjectFoo = object { Def of an object } procedure DoAction; constructor Init; destructor Done; end; SubrangeFoo = -123..456; { subrange def }

EnumeratedFoo = (Pope,John,the,Second); { enum type def } { Def of a pointer to another type identifier } PInteger = ^arrayfoo; { Def of an alias name for another type identifier } IdentityFoo = Integer; { Def of an integer which was initialized by 123 } InitializedFoo = Integer value 123;

See also

section 8.2.1 Type Definition, section 8.2 Data Types, section 8.1.5 Variable Declaration


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html