[fpc-pascal] FPC's behavior regarding new TObject methods

Sven Barth pascaldragon at googlemail.com
Sat Nov 13 14:37:12 CET 2010


On 13.11.2010 14:28, Michael Van Canneyt wrote:
>
>
> On Sat, 13 Nov 2010, Sven Barth wrote:
>
>> Hello together!
>>
>> I've installed FPC 2.4.2 and after reading the page about the changes
>> since 2.4.0, I've compiled Lazarus and noticed a warning in imglist.pp
>> regarding a Equals method (already reported). Now I remembered that
>> http://wiki.freepascal.org/User_Changes_2.4.2#TObject_class_declaration mentions
>> that FPC warns in mode delphi, but generates an error in mode objfpc.
>> So I looked at the top of the unit, but did found "{$mode objfpc}".
>>
>> Puzzled, I wrote the following test program:
>>
>> ==== source begin ====
>>
>> ==== source end ====
>>
>> Compiling it with FPC 2.4.2 (and 2.5.1 as well) results only in
>> warnings regarding the methods Equals and ToString and not errors as
>> expected after reading the wiki.
>>
>> So who is right?
>> a) the wiki (thus there is a bug in FPC - very bad, because 2.4.2 is
>> already released)
>> b) the compiler (thus the wiki is wrong)
>
> The compiler is right. You can always re-introduce methods.
> But if you call 'TObject.Equals', your (wrongly declared) method will
> not be called.
> Standard OOP inheritance/overriding rules.

As told to Paul I've misunderstood the wiki entry. More precisely the 
part "identifier". :)

Now the world is beautiful again :P

Regards,
Sven



More information about the fpc-pascal mailing list