toString() through interface
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Apr 21 06:23:50 PDT 2014
On Sat, 19 Apr 2014 20:45:50 -0400, Adam D. Ruppe
<destructionator at gmail.com> 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.
This is also not true. Only interfaces derived from IUnknown point to a
COM object. Only interfaces marked as extern(C++) can point to a C++
object.
Any interface that is purely D MUST point at a D object that derives from
Object, EVEN D-defined COM or C++ objects (the latter doesn't really
exist).
His code should compile IMO.
> 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!
As stated above, this is not possible.
-Steve
More information about the Digitalmars-d-learn
mailing list