OpEquals and Interfaces
Steven Schveighoffer
schveiguy at yahoo.com
Wed Apr 14 04:51:28 PDT 2010
On Wed, 14 Apr 2010 07:29:28 -0400, Don <nospam at nospam.com> wrote:
> Steven Schveighoffer wrote:
>> On Tue, 13 Apr 2010 19:47:13 -0400, Jason House
>> <jason.james.house at gmail.com> wrote:
>>
>>> Steven Schveighoffer Wrote:
>>>
>>>> On Tue, 13 Apr 2010 15:50:36 -0400, Christoph Mueller
>>>> <ruunhb at googlemail.com> wrote:
>>>>
>>>> > I'm currently writing a library in D2 which uses intensively
>>>> interfaces
>>>> > and i meet a problem by overloading the opEquals Operator.
>>>> >
>>>> > In some of my implementations i want to compare an object through an
>>>> > interface of another instance
>>>> >
>>>> > Unfortanetly, the opEquals Operator uses only Object parameters and
>>>> > according to the current DMD-Compiler it's not possible to cast
>>>> implicit
>>>> > an Interface to an Object. (Got a nice compiler error)
>>>> >
>>>> > Is there any reason to forbid implicit downcasting from any
>>>> interface to
>>>> > Object?
>>>>
>>>> Any good reason? No.
>>>>
>>>> But the stated reason is usually that interfaces don't necessarily
>>>> have to
>>>> be Objects, they can be COM objects, which 1) has no bearing in some
>>>> OSes,
>>>> and 2) does anyone use this feature?
>>>
>>> It could also be a C++ class
>>>
>> C++ classes are already tagged with extern(C++) (i.e. there's a
>> difference the compiler can grip to make it behave differently)
>> Maybe that's the solution, make COM solutions extern(COM), or @COM or
>> something. That's fine also. Anything to then allow the compiler to
>> assume unadorned interfaces are D objects.
>> -Steve
>
> I think we can just use extern(C++).
If this is true, this is a no brainer!
This shows my ignorance of COM or why IUnknown is a special interface :)
If it's just because it's a C++ interface, then yeah, let's set that up.
searching for D's explanation of how COM interfaces work I found this
really helpful page :P
http://www.digitalmars.com/d/2.0/COM.html
Walter, can you confirm that extern(C++) interfaces are equivalent to
inheriting IUnknown? If not, what are the differences?
-Steve
More information about the Digitalmars-d
mailing list