[DUG] Accessing an ancestor class private field

Kyley Harris kyleyharris at gmail.com
Fri Jun 10 12:34:52 NZST 2005


It's Friday. If we weren't ranting about stuff like this we'd have to
talk politics. Then it''d get really messy :D

On 6/10/05, Conor Boyd <lists at conor.org.uk> wrote:
> 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.
> 
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
> 


-- 
Kyley Harris
Harris Software
+64-9-8455274
+64-21-671-821



More information about the Delphi mailing list