Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi IComparable in XE7 (https://www.delphipraxis.net/182464-icomparable-xe7.html)

Neutral General 27. Okt 2014 13:08

Delphi-Version: XE5

IComparable in XE7
 
Hallo,

Ich weiß nicht ob ich gerade auf dem Schlauch stehe oder ob da in Delphi irgendwas kaputt ist.

Folgender Code von mir:

Delphi-Quellcode:
type
  TKlasse = class(TInterfacedObject, System.IComparable<TForm>)
  public
    function CompareTo(Value: TForm): Integer;
  end;


function TKlasse.CompareTo(Value: TForm): Integer;
begin
  Result := 0; // Was auch immer..
end;
Delphi bringt mir nun die Meldung:

Delphi-Quellcode:
[dcc32 Fehler] Unit1.pas(18): E2291 Implementierung der Interface-Methode IComparable.CompareTo fehlt

Warum denn das?
IComparable<T> ist so definiert:

Delphi-Quellcode:
IComparable<T> = interface(IComparable)
  function CompareTo(Value: T): Integer;
end;
Ist Delphi blöd oder steh ich grad aufm Schlauch?

Edit: Habs. IComparable (nicht generisch) hat natürlich auch eine CompareTo-Methode und die muss ich dann noch zusätzlich implementieren:

Delphi-Quellcode:
type
  TKlasse = class(TInterfacedObject, System.IComparable<TForm>)
  public
    function CompareTo(Obj: TObject): Integer; overload;
    function CompareTo(Value: TForm): Integer; overload;
  end;
Das war früher aber nicht.. Ist das so gewollt? Weil das ist doch irgendwie bescheuert -.-

DeddyH 27. Okt 2014 13:24

AW: IComparable in XE7
 
http://qc.embarcadero.com/wc/qcmain.aspx?d=104299
Zitat:

System.IComparable<T> inherits from the not generic IComparable!
So if your class implements IComparable<T> it also has to implement IComparable.
...
This is not very elegant, but it is the consequence of the design in the Delphi RTL.

Neutral General 27. Okt 2014 13:37

AW: IComparable in XE7
 
Naja sie sehen immerhin ein dass es nicht besonders schön ist :X


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:06 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz