Icon Type Declarations

Type declarations must be in the following format:

<Type Declaration> | <Function/Procedure Type Declaration> | <Method Type Declaration> | <Class Declaration>;
[<Type Declaration> | <Function/Procedure Type Declaration> | <Method Type Declaration> | <Class Declaration>;]

<Type Declaration> =

   <Synonym Type Name> = [type] <Type Name>;

<Function/Procedure Type Declaration> =

   <Function/Procedure Type Name> = function|procedure ([<Parameters>])[: <Type Name>];

<Method Type Declaration> =

   <Method Type Name> = function|procedure ([<Parameters>])[: <Type Name>] of object;

<Class Declaration> =

   <Class Name> = class [(<Ancestor Class Name>)]
      [<Private Class Members>]
      [<Protected Class Members>]
      [<Public Class Members>]

The <Synonym Type Name>, <Type Name>, <Method Type Name>, <Class Name>, and <Ancestor Class Name> elements must follow the rules for identifiers covered in the Introduction topic, and each type or class declaration must be terminated with a semicolon statement terminator (;).

A synonym type declaration is useful for situations where one wants to use a specific name for a generic type such as an Integer, String, or Boolean. For example, in the Elevate Web Builder component library, the following type declaration can be found in the WebUI source unit:

TColor = type Integer;

The optional type keyword found before the Integer type name above is used to specify that the declared type (TColor) should be considered unique for design-time type distinction purposes, and essentially creates a new Integer type called TColor. The Elevate Web Builder IDE design-time environment uses this information to determine which property editors to show for certain types.

Information The synonym type retains type compatibility with the type name that it is associated with. For example, with the above declaration the compiler will still allow you to use an Integer in any expression where a TColor type is required.

A function/procedure type declaration is used to declare a function/procedure reference type. Function/procedure references point to a function/procedure implementation, and are used to treat functions/procedures as data. The Elevate Web Builder compiler automatically figures out when a function/procedure reference is being assigned to a variable declared with such a reference type, and when a variable that is declared with such a reference type is being used to call the function/procedure reference contained in the variable. You can only assign references to functions/procedures that have the same signature as the target variable's function/procedure reference type. For example, this assignment is not valid:


TFuncRef = function (Value: Integer): Integer;  // Returns Integer


function DoSomething(Value: Integer): Boolean;  // Returns Boolean

procedure DoSomethingElse;
   FuncRef: TFuncRef;
   FuncRef:=DoSomething;  //  This will cause a compiler error !!!!

A method type declaration is used to declare a method reference type. A method reference type is like a function/procedure reference type, except that it also includes the class instance to be used when calling the method contained within a variable declared with a method reference type. For more information on method reference type declarations, please see the Events topic.

A class declaration can include an ancestor class name, if applicable. If one is declaraing a class that inherits from the base TObject class, then the ancestor class name does not need to be specified. For more information on class declarations, please see the Classes topic.