AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

IComparable in XE7

Ein Thema von Neutral General · begonnen am 27. Okt 2014 · letzter Beitrag vom 27. Okt 2014
Antwort Antwort
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

IComparable in XE7

  Alt 27. Okt 2014, 14:08
Delphi-Version: XE5
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:

[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 -.-
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."

Geändert von Neutral General (27. Okt 2014 um 14:10 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.534 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: IComparable in XE7

  Alt 27. Okt 2014, 14:24
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.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: IComparable in XE7

  Alt 27. Okt 2014, 14:37
Naja sie sehen immerhin ein dass es nicht besonders schön ist :X
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:23 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