OpEquals and Interfaces
Steven Schveighoffer
schveiguy at yahoo.com
Tue Apr 13 16:16:21 PDT 2010
On Tue, 13 Apr 2010 17:27:20 -0400, Christoph Mueller
<ruunhb at googlemail.com> wrote:
>> If you are using D2, there is a workaround:
>>
>> interface I
>> {
>> final bool opEquals(I other)
>> {
>> Object me = cast(Object)this;
>> Object they = cast(Object)other;
>> return equals(me, they);
>> }
>> }
>>
>> But it would be nice if the compiler did this automatically. There are
>> other things that suck because interfaces are not assumed to be derived
>> from Object.
>
> What kind of things also doesn't work relating to interfaces and Object ?
Any base method of Object -- opCmp, toHash, or simply passing an interface
to a function that accepts an Object.
There are others, but I can't think of them right now.
-Steve
More information about the Digitalmars-d
mailing list