Comparing interfaces does not call opEquals

Bill Baxter wbaxter at gmail.com
Tue Jul 29 12:45:01 PDT 2008


On Wed, Jul 30, 2008 at 3:06 AM, Frank Benoit <keinfarbton at googlemail.com>wrote:

> interface I {
> }
> class C : I {
>  override int opEquals(Object o){
>    writefln("opEquals");
>    return true;
>  }
> }
>
> void main(){
>  I i1 = new C;
>  I i2 = new C;
>  bool a = ( i1 == i2 );
>  writefln( "result %s", a );
> }
>
> prints
> result false
>
> This is highly unexpected.
> Sure one might understand that with the knowledge of interface/class
> incompatibility in D. But this shows once more, that D has a Bug here.
>
>
>
>
What is the reason that COM interfaces need to pretend to be D interfaces in
the first place?  As opposed to some special COMInterface type.  I can't
really think of any situation where you would need to treat a COM interface
and a regular interface the same way without knowing that one was a COM
interface.  Or at least in a way that it would matter.  For instance you
could write a template that takes either a COM interface or a D interface,
but in that case you generally won't care what the thing is underneath.

Can someone enlighten me?  I've never really been able to understand what
problem is supposed to be solved by conflating D Interfaces and COM
interfaces.

--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20080730/92aaf6d6/attachment.html>


More information about the Digitalmars-d mailing list