OpEquals and Interfaces
Steven Schveighoffer
schveiguy at yahoo.com
Tue Apr 13 16:17:58 PDT 2010
On Tue, 13 Apr 2010 19:16:21 -0400, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> 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.
Add toString to that, that's a biggie...
-Steve
More information about the Digitalmars-d
mailing list