[fpc-devel] property cam access private symbol from class in other unit

Martin lazarus at mfriebe.de
Wed Jan 4 21:10:09 CET 2012


On 04/01/2012 20:01, Pete Cervasio wrote:
>
> On Wednesday, January 04, 2012 01:26:52 pm Martin wrote:
>
> > TForm1 = class(TForm)
>
> > public
>
> > FFoo: TFoo;
>
> > property Num: Integer read FFoo.FBar;
>
> > end;
>
> Just a 'for your info' note: Kylix doesn't allow the above. Nor does 
> it allow accessing the property FFoo.Bar as a parameter to the read. 
> This makes sense to me, though, because FFoo may very well be nil when 
> code tries to read Form1.Num.
>
>

Well the property is rejected by fpc too. But then a property is always 
treated as if it was a function (or procedure for the setter). So that 
is more than referring to a field.

To be honest I discovered this by accident, it was meant to use a field 
from a record...

the nil situation is not a concern here, a programmer can always write 
code that can fail on nil pointers. FFoo could well have the same live 
time as the Form...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20120104/b9f37c78/attachment.html>


More information about the fpc-devel mailing list