[fpc-pascal] Record helper properties
Ryan Joseph
ryan at thealchemistguild.com
Wed Apr 24 02:36:29 CEST 2019
> On Apr 23, 2019, at 8:28 PM, Alexander Grotewohl <alex at dcclost.com> wrote:
>
> http://wiki.freepascal.org/Helper_types
>
> under the checklistbox extender example.
>
> I'd guess it's looking for THelper.GetX and THelper.SetX in your and not finding them
>
Oh now I get it. Is this what I should be doing? I really didn’t want those getters so I’m putting them as strict private. The error message could be better on this.
Honestly this seems kind of crazy though. We’re making all this boiler plate because published fields? Why not just allow field access unless there are published fields? I’ve never used published fields personally so it’s an unfortunate restriction.
program test;
type
TRec = record
x: integer;
end;
type
THelper = record helper for TRec
strict private
function GetX: integer; inline;
procedure SetX (newValue: integer); inline;
public
property F: integer read GetX write SetX;
end;
function THelper.GetX: integer;
begin
result := x;
end;
procedure THelper.SetX (newValue: integer);
begin
x := newValue;
end;
begin
end.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list