OpEquals and Interfaces

Don nospam at nospam.com
Wed Apr 14 04:29:28 PDT 2010


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++).



More information about the Digitalmars-d mailing list