[fpc-devel] comparing methods

Mattias Gärtner nc-gaertnma at netcologne.de
Thu Sep 10 12:37:21 CEST 2009


Hi,

Can someone explain why in mode objfpc comparing methods only compares  
the address, but not the instance?
For example:

   a:=TMyClass.Create;
   b:=TMyClass.Create;
   if @a.test = @b.test then writeln('the same method');

This results in strange behaviors, when using the following code (from  
the FCL):

property AfterConnect: TNotifyEvent read FAfterConnect write SetAfterConnect;

procedure TCustomConnection.SetAfterConnect(const AValue: TNotifyEvent);
begin
   if FAfterConnect=AValue then exit;
   FAfterConnect:=AValue;
end;


Mattias





More information about the fpc-devel mailing list