[fpc-devel] comparing methods

Mattias Gärtner nc-gaertnma at netcologne.de
Fri Sep 11 11:00:00 CEST 2009


Zitat von Michael Schnell <mschnell at lumino.de>:

> Mattias Gärtner wrote:
>>
>> The @ operator is more than "address of".
>>
>
> Hmm "Address of" is not that simple in itself. :)
>
> With a "Procedure of Object", "@" of course handles the Self pointer, too.
>
> I suppose to find the address of a function "@" uses the Virtual Method
> Table found with the Self pointer.
>
> So in fact there are (at least) two ways of implementing a compare
> between two pointers to "Procedure of Object" variables, that IMHO both
> make sense:
>
> 1) Simply compare the Self and the Address part (the same function of
> two implementations of a class are different)
>
> 2) Compare only the address (the same function of two implementations of
> a class are identical, unless overloaded by a child's function).
>
> I think it's a matter of taste (I do vote for (2) ).

No.
It is a matter of consistency.

The current comparison is not intuitive. This is proven by the many  
places where it used wrong and the almost zero places where it is used  
right (Is there any one at all?).

The problems are:

1. It exists for years, so there might be code depending on this. I  
doubt this.

2. It is Delphi/TP compatible. So it can not be done in mode  
delphi/tp. That's why I propose to change it in mode objfpc.

If the compiler team refuses to change it, can at least a "hint" be given?


Mattias




More information about the fpc-devel mailing list