On 4/19/2014 5:45 PM, Adam D. Ruppe wrote:
On Sunday, 20 April 2014 at 00:35:30 UTC, David Held wrote:
Since all implementations of an interface must derive from Object

That's not true. They can also come from IUnknown or a C++ interface.

Ok, that's a good reason!

    cast(Object)(foo).toString();

(cast(Object)foo).toString() might work


This might return null tho if it is a non-D object through the interface!

Yes, I later discovered that I didn't understand the cast syntax properly. This does indeed work, but leads to the discovery that Object.toString() is not pure. :( But that's tolerable. Also, declaring toString() in the interfaces avoids the need for a cast entirely, although I feel this is a bit of a dirty hack.

Dave

Reply via email to