Confused about interfaces in D

Jarrett Billingsley jarrett.billingsley at
Thu Oct 2 16:42:09 PDT 2008

On Thu, Oct 2, 2008 at 7:36 PM, Bryan Power <bp2626 at> wrote:
> Bill Baxter wrote:
>> When it's derived from IUnknown, a special case put in to support COM
>> interfaces on Win32.
>> I've not heard anyone voice support for this particular design decision.
>> I suppose it's very convenient if you happen to be a COM programmer,
>> but I'm not sure why a vendor-specific technology like COM should get
>> such special treatment in a language spec.
>> --bb
> Steven Schveighoffer wrote:
>> The issue is totally with COM.
>> Without the requirement for any interface to possibly be a COM interface,
>> all interfaces would implicitly inherit from ObjectInterface or some
>> interface that always has the functions required in Object defined (e.g.
>> toString()).
>> But COM objects don't have the same base functions as Object does, so
>> interfaces have no required base functions.  Making life difficult for those
>> who never ever work with COM (and I can't say I blame them, COM sucks).
>> -Steve
> A fair bit of extended API functionality on Windows is presented via COM.
> This includes very important API sets like DirectX, which is implemented via
> COM. A bonus of COM is that it allows use of the API in its OOP form in C++
> while still allowing the API to be used in procedural languages like IA32, C
> and Pascal without any hacks or tricks.
> Even Mozilla has their own COM implementation.
> While I admit COM can be messy at times, I use it almost daily for my work,
> and since I am free to use the languages of my choosing I generally use D.
> This interface feature allows me to port COM definitions from the C/C++
> headers to D seamlessly
> and quickly:
> interface IWbemObjectSink : IUnknown {}
> for example.
> I am all for the COM compatibility.

I am as well, but treating it as the general case makes no sense.
IUnknown and anything derived from it should be treated as special
cases; anything else should be implicitly castable to Object.

More information about the Digitalmars-d-learn mailing list