interface reference not compatible to Object?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat Oct 21 06:11:59 PDT 2006


Frank Benoit (keinfarbton) wrote:
>>> Is this the intended behaviour? If *every* object in D is a Object, then
>>> every interface reference refers to an Object also. This said, the above
>>> should compile?
> 
> And as already said in #d : I wonder why this even compiles. Why is C
> not enforced to "reimplement" the methods from IObject?

I guess because the interface only requires the methods to be 
implemented, but allows them to be implemented in a base class as well 
as the class itself.

> Wouldn't it be consistent if the compiler implicitly inherit all
> interfaces without a super-interface from this IObject?

Maybe Object itself as well?
That way functions can accept any object (whether referenced by class or 
interface) as an IObject.

Though I would prefer it if all interface references would just be 
implicitly convertible to Object. Java does this, IIRC.



More information about the Digitalmars-d mailing list