uses System.TypInfo;
type
TPoint<T> = record
X, Y: T;
//standalone generic functions are
//not allowed: a method of the
//generic record; matching by TypeInfo
function Describe: string;
end;
function TPoint<T>.Describe: string;
begin
if TypeInfo(T) = TypeInfo(Integer) then
Result := 'Point (int, int)'
else if TypeInfo(T) = TypeInfo(Double) then
Result := 'Point (float, float)'
else
Result := 'Unknown';
end;
var
P1: TPoint<Integer>;
P2: TPoint<Double>;
begin
P1.X := 3;
P1.Y := 4;
WriteLn('desc1 is ', P1.Describe);
//desc1 is Point (int, int)
P2.X := 7.1;
P2.Y := 4.6;
WriteLn('desc2 is ', P2.Describe);
//desc2 is Point (float, float)
end.