[fpc-pascal] Record helper properties

Tomas Hajny XHajT03 at hajny.biz
Wed Apr 24 03:36:45 CEST 2019


On 2019-04-24 02:36, Ryan Joseph wrote:
>> 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
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list