8.5.1 Syntax elements

The syntax shown in the syntax diagrams is the syntax required in the ObjFPC mode of the compiler. However, in Delphi mode, the specialize and generic keywords must not be used, as shown in the following example:

Type  
  TTest<T> = Class(TObject)  
  Private  
    FObj : T;  
  Public  
    Property Obj : T Read FObj Write FObj;  
  end;  
 
  TIntegerTest = TTest<Integer>;

In difference with Mode Objfpc, the template type names must be repeated in method definitions.

Type  
  TTest<T> = Class(TObject)  
  Private  
    FObj : T;  
  Public  
    Procedure DoIt;  
    Property Obj : T Read FObj Write FObj;  
  end;  
 
Procedure TTest<T>.DoIt;  
 
begin  
end;

This requirement is directly related to the generic type overload capability mentioned in the next section.