interfaces and such
Steven Schveighoffer
schveiguy at yahoo.com
Mon Aug 27 06:29:48 PDT 2012
On Fri, 24 Aug 2012 22:01:51 -0400, Chris Nicholson-Sauls
<ibisbasenji at gmail.com> wrote:
> On Friday, 24 August 2012 at 14:15:28 UTC, Steven Schveighoffer wrote:
>> On Fri, 27 Jul 2012 12:48:59 -0400, David Nadlinger <see at klickverbot.at>
>> wrote:
>>
>>> On Friday, 27 July 2012 at 14:56:18 UTC, Gor Gyolchanyan wrote:
>>>> I have a small question: why aren't interfaces implicitly convertible
>>>> to
>>>> Object?
>>>
>>> Not all interfaces »originate« from D objects, they can also be COM
>>> interfaces. Using (cast(Object)foo) should work if foo is really an
>>> Object.
>>
>> All Com interfaces inherit from IUnknown. This is statically known.
>>
>> The idea that we cannot tell which interfaces are COM and which are
>> normal
>> is a myth.
>>
>> There is no reason why interfaces (that aren't COM) shouldn't be
>> implicitly castable to Object.
>>
>> -Steve
>
> Technically true, however COM is not the only example of foreign objects
> used via interfaces. The (limited) C++ compatibility, for example,
> works this way.
Those are extern(C++), also statically known.
In fact, the very nature of how interfaces work makes it very difficult
for us to *not* statically know that an interface is a D interface -- D's
implementation of interfaces is not like any others.
-Steve
More information about the Digitalmars-d
mailing list