[fpc-pascal] Record helper properties
Ryan Joseph
ryan at thealchemistguild.com
Wed Apr 24 01:25:00 CEST 2019
> On Apr 23, 2019, at 6:25 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> A helper can not access its extended type in its interface, only in its implementation (and yes, this gets important if published properties are involved, which a helper may declare as well).
> Use a getter as a workaround. If you use "inline" chances are high that it will be nearly equal code as if you used a direct access.
>
Still getting errors. What did I do wrong?
{$mode objfpc}
{$modeswitch advancedrecords}
program test;
type
TRec = record
x: integer;
function GetX: integer;
procedure SetX (newValue: integer);
end;
function TRec.GetX: integer;
begin
result := x;
end;
procedure TRec.SetX (newValue: integer);
begin
x := newValue;
end;
type
THelper = record helper for TRec
property F: integer read GetX write SetX; // ERROR: Unknown class field or method identifier "GetX"
end;
begin
end.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list