title: Delphi 2009: Is it possibly dangerous to use TList<[any interface]> with default comparator?
body: <p>I am wondering if the usage of a generic <code>TList&lt;T&gt;</code> where <code>T</code> is any interface type (except <code>IUnknown</code>/<code>IInterface</code>) might be dangerous. I am heavily using interfaces and store them in lists. Some interfaces are my own, some are provided by some COM-interfaces, so COM is involved.</p>
  
  <p>I see a potential problem where checks for instance-equality happens, e.g. when I use the <code>Remove</code> method of the list (which internally needs to compare my provided value to the contained values). According to COM-rules you can only compare two interfaces for equality after casting them to <code>IUnknown</code>. I don't know if the default comparator involved in finding my interface in the <code>TList&lt;T&gt;</code> is aware of that.</p>
  
  <p>To illustrate my question with an example:</p>
  
  <pre><code>var
    list:TList&lt;IMyInterface&gt;;
    intf:IMyInterface;
  begin
    ...
    list:=TList&lt;IMyInterface&gt;.Create;
    list.Add(intf);
    ...
    list.Remove(intf);
  end;
  </code></pre>
  
  <p>Is the above code legitimate?</p>