[lazarus] Possible compiler bug with derived classes?

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Nov 4 06:08:21 EST 1999




On Thu, 4 Nov 1999, Chris Storah wrote:

> >Can you tell me WHICH rec it takes when you refer to it ?
> Delphi takes the rec of the TVer2 class.
> 
> >How is the compiler supposed to know in a descendent class which one to
> take ? 
> Delphi takes the descendent class 'rec', as it does with the virtual
> members.
> Surely if the descendent class overrides a member of it's base class, that
> is the one to be used?

Not if it is protected; Private: yes, but not protected nor public, nor
published.

> 
> >if you declare such a thing in the protected part, you should rename it.
> The problem is not limited to the protected members (change it to 'public'
> and the same thing happens).


> 
> >..simply bad programming to do this
> I agree that it's not the best approach, but what if you need some code that
> does the same processing on file records and you change the record structure
> at a later date. If you have to change 'rec' to something else, then the
> processing code will need to change from being generic to version specific
> (i.e. processing 'recVer1,2,3...N' instead of rec).

Change the rec with a class and then it's solved :-)


> >Delphi has other strange quircks; 
> Does this work on other versions of Pascal?
> I have only tried it on Delphi and ppc386 so I can't verify that it is a
> quirk or not.

Maybe a quirck is a bad name; I meant more that Delphi allows some
things which go against good pascal programming.

Michael.






More information about the Lazarus mailing list