[DUG] Accessing an ancestor class private field

Conor Boyd lists at conor.org.uk
Fri Jun 10 12:16:06 NZST 2005


Fair enough.

Like I indicated earlier, I don't really have enough experience in this
particular area to comment on the limits of RTTI, but I thought it was worth
Todd investigating.

Cheers,

C. 

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of Kyley Harris

I think you need to accept that it is not possible to access a private
variable using RTTI unles it was exposed via a published property, as is the
case of FITems in TCollection.

What I proposed is and always will be a hack, and is not the easiet or
fastest way. The "Real" way is to design an object with inheritance in mind
and make things accessible. This is not always possible, so you refactor the
code. So people don't like to refactor classes.pas, because its library
source. I'll change it just as fast as I'll change 3rd party source, if it
has a bug in it.

So my debatable opinion is to refactor the code. RTTI is a useful tool that
works on a correctly designed object, but it is not a getaround to private
variables

On 6/10/05, Conor Boyd <lists at conor.org.uk> wrote:
>  
> I still think RTTI is the only "real" way, but I accept it's more work 
> than yours or Kyley's suggestions.



More information about the Delphi mailing list