interface reference not compatible to Object?

Max Samuha maxter at i.com.ua
Sat Oct 21 08:44:48 PDT 2006


On Sat, 21 Oct 2006 15:11:59 +0200, Frits van Bommel
<fvbommel at REMwOVExCAPSs.nl> wrote:

>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.

The problem is that not all objects in D are D objects. An interface
may be a com interface that cannot be cast to Object or inherit from
IObject. It was discussed somewhere in the NG, IIRC



More information about the Digitalmars-d mailing list