Assigning Interface to Object

Stewart Gordon smjg_1998 at yahoo.com
Sun Jan 16 05:11:45 PST 2011


On 16/01/2011 08:23, "Jérôme M. Berger" wrote:
> Stewart Gordon wrote:
>> On 15/01/2011 17:44, Steven Schveighoffer wrote:
>> <snip>
>>> Which unnecessarily complicates things. For example, you can't compare
>>> two interfaces (try it!).
>>
>> ?
> interface I {}
>
> ...
>
> I a = ...;
> I b = ...;
>
> if (a == b) //<-- ERROR


1.065: compiles without error, though it seems to be equivalent to is
2.051: it's really weird
----------
C:\Users\Stewart\Documents\Programming\D\Tests>dmd interface_equals.d
interface_equals.d(7): Error: function object.opEquals (Object lhs, 
Object rhs)
is not callable using argument types (I,I)
interface_equals.d(7): Error: cannot implicitly convert expression (a) 
of type i
nterface_equals.I to object.Object
interface_equals.d(7): Error: cannot implicitly convert expression (b) 
of type i
nterface_equals.I to object.Object
----------

Of course, if the interface declares an opEquals, it's a whole different 
story....

Stewart.


More information about the Digitalmars-d-learn mailing list