object - interface compatibility

Frank Benoit (keinfarbton) benoit at tionex.removethispart.de
Tue Nov 14 09:07:33 PST 2006


Today I had a hard lesson to learn. An iface and an object is not
exchangeable. The reference to an object is manipulated if it is casted
to an interface type.

This happens implicit if an object is passed to a var/meth which wants
it to be type of iface.

But this does not happen implicit if you want to pass and array of
objects. This is, because it would mean to iterate over the array, cast
piece-wise and build a new array.
But the consequence is, that the user of the class has to distinguish
between class types and iface types.

I wonder if this should really be in that way?
Is this documented?



More information about the Digitalmars-d mailing list