object - interface compatibility
Walter Bright
newshound at digitalmars.com
Tue Nov 14 11:55:25 PST 2006
Frank Benoit (keinfarbton) wrote:
> 1.) Is this reference manipulation really absolutely necessary? Why?
There are two ways to implement interfaces. One is where the
determination of what functions to call is done by repeated testing of
an object to see what interfaces it supports. This is slow. The other
way is to do it like C++ does multiple inheritance. Interfaces are
really "multiple inheritance lite", and D does it the C++ way, which is
very efficient at runtime.
> 2.) Isn't there a way to make class and iface really compatible?
Consider a function that takes an interface as an argument. Two
different objects, A and B, can implement that interface. How can the
function tell that it can call A.foo() when it gets an interface derived
from A, when B doesn't have a .foo()?
> 3.) Please document this very cleanly in the D spec.
More information about the Digitalmars-d
mailing list