interface reference not compatible to Object?

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Sat Oct 21 08:47:04 PDT 2006


Frits van Bommel wrote:
> Frank Benoit (keinfarbton) wrote:
>> 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.

AFAIK it's the basis for developing high level software architectures in
languages that lack multiple inheritance of objects but allow multiple
inheritance of interfaces, e.g. Java.

It's pretty cool that someone came up with this in #d, but seriously irc
is not the best place for documenting things. This information should be
in the official documentation.

The official documentation clearly tells how you can write classes that
implement interfaces and that the compiler bugs you, if the class does
not implement all abstract methods. This is very good, but the
documentation is dead silent about dereferencing objects via interfaces.
I guess it's because Walter is mainly a C++ guy and does not yet
understand how interfaces work in Java. D has the same mechanism for
interfaces as Java does. Why then should interfaces in D work like they
work in C++, i.e. they do not work because C++ does not have any interfaces!



More information about the Digitalmars-d mailing list