Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-05

properties accessing field of nested object ?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

I know a property read/write to a member of a record, if that record is a field of the class.

I tested the following code, it seems fpc also allows that for classes.

type
   TFoo = class
   protected
     cn: Integer;
   end;
   TForm1 = class(TForm)
   private
     a:TFoo;
   public
     property b: Integer read a.cn write a.cn;
   end;

I have not tested it at runtime.... I assume it depend on a being initialized with an instance.

Question, is that allowed by intention? That is can I trust that it will be supported by future fpc versions?

Or is that a missing check somewhere, and bay stop working in future?

Reply by email

Michael Van Canneyt
to Martin
Martin wrote 25 lines
I know a property read/write to a member of a record, if that record is a field of the class. I tested the following code, it seems fpc also allows that for classes. type TFoo = class protected cn: Integer; end; TForm1 = class(TForm) private a:TFoo; public property b: Integer read a.cn write a.cn; end; I have not tested it at runtime.... I assume it depend on a being initialized with an instance. Question, is that allowed by intention? That is can I trust that it will be supported by future fpc versions? Or is that a missing check somewhere, and bay stop working in future?

I think the latter, unless this was added recently as a feature. At least in RTTI there is no support for getting/setting fields as part of a class-typed field?

Michael.

Reply by email

Martin
to Michael Van Canneyt
Michael Van Canneyt wrote 15 lines
On Sun, 12 May 2013, Martin wrote: > > I have not tested it at runtime.... I assume it depend on a being > initialized with an instance. > > Question, is that allowed by intention? That is can I trust that it > will be supported by future fpc versions? > > Or is that a missing check somewhere, and bay stop working in future? I think the latter, unless this was added recently as a feature. At least in RTTI there is no support for getting/setting fields as part of a class-typed field?

Makes sense, since it does not work for properties, but only for fields.

The access to record fields is intended though?

Reply by email

Paul Ishenin
to Martin

13.05.13, 18:36, Martin пишет:

Makes sense, since it does not work for properties, but only for fields. The access to record fields is intended though?

Yes.

Best regards,
Paul Ishenin

Reply by email