[fpc-pascal] Class field property access
Tomas Hajny
XHajT03 at hajny.biz
Mon Jun 3 16:43:10 CEST 2019
On 2019-06-03 16:01, Ryan Joseph wrote:
> I found a restriction in properties which is a little disappointing. I
> get there’s probably some objective of safety but Pascal is a direct
> memory access language so I don’t understand why properties have this
> unique restriction when I could do the same thing using functions
> (pointers can’t be dereferenced in properties either). Shouldn’t I as
> the programmer get to decide whether the property is safe or not based
> upon when I call it?
>
> type
> TB = class
> x: integer;
> end;
>
> type
> TA = class
> private
> b: TB;
> public
> property x: integer read b.x; // ERROR: Must be a record/object
> type
> end;
Which mode / which FPC version? It compiles without complaints for me
with FPC 3.0.4 and either -Mobjfpc or -Mdelphi (after adding 'begin
end.' to the end to make it a valid / compilable "program".
Tomas
More information about the fpc-pascal
mailing list