Quick start manual
Data types, variables, and constants
5-39
Declaring types
• T1 and T2 are compatible packed-string types.
• T1 and T2 are compatible set types.
• T1 and T2 are compatible pointer types.
• T1 and T2 are both class, class-reference, or interface types and T2 is a derived
from T1.
• T1 is an interface type and T2 is a class type that implements T1.
• T1 is PChar or PWideChar and T2 is a zero-based character array of the form
array[0..n] of Char (when T1 is PChar) or of WideChar (when T1 is PWideChar).
• T1 and T2 are compatible procedural types. (A function or procedure identifier is
treated, in certain assignment statements, as an expression of a procedural type.
See “Procedural types in statements and expressions” on page 5-32.)
• T1 is Variant and T2 is an integer, real, string, character, Boolean, interface type or
OleVariant type.
• T1 is an OleVariant and T2 is an integer, real, string, character, Boolean, interface,
or Variant type.
• T1 is an integer, real, string, character, or Boolean type and T2 is Variant or
OleVariant.
• T1 is the IUnknown or IDispatch interface type and T2 is Variant or OleVariant. (The
variant’s type code must be varEmpty, varUnknown, or varDispatch if T1 is
IUnknown, and varEmpty or varDispatch if T1 is IDispatch.)
Declaring types
A type declaration specifies an identifier that denotes a type. The syntax for a type
declaration is
type newTypeName = type
where newTypeName is a valid identifier. For example, given the type declaration
type TMyString = string;
you can make the variable declaration
var S: TMyString;
A type identifier’s scope doesn’t include the type declaration itself (except for pointer
types). So you cannot, for example, define a record type that uses itself recursively.
When you declare a type that is identical to an existing type, the compiler treats the
new type identifier as an alias for the old one. Thus, given the declarations
type TValue = Real;
var
X: Real;
Y: TValue;