Это работает (см. Синтаксические комментарии в коде):
Type
TRec = record
s: string;
p: procedure; // As Ken pointed out, better define a procedural type:
// type TMyProc = procedure; and declare p : TMyProc;
end;
procedure run; forward; // The forward is needed here.
// If the procedure run was declared in the interface
// section of a unit, the forward directive should not be here.
Const
Rec: TRec = (s:''; p:run); // The const record is predefined by the compiler.
procedure run;
begin
WriteLn('Test');
end;
begin
Rec.p; // Rec.run will not work since run is not a declared member of TRec.
// The array index (Rec[0]) is not applicable here since Rec is not declared as an array.
ReadLn;
end.