February 13, 2017
Dne 13.2.2017 v 14:12 Kagamin via Digitalmars-d napsal(a):

> On Saturday, 11 February 2017 at 05:19:37 UTC, Walter Bright wrote:
>> not all interfaces are Objects
>
> Do you have an example? How it can be? Only classes can implement interfaces, and classes inherit from Object.
Not all classes, extern(C++) classes does not
February 13, 2017
On Monday, 13 February 2017 at 13:18:33 UTC, Daniel Kozak wrote:
> Not all classes, extern(C++) classes does not

C++ only has C++ interfaces and they are different from D interfaces.
February 13, 2017
Dne 13.2.2017 v 14:12 Kagamin via Digitalmars-d napsal(a):

> On Saturday, 11 February 2017 at 05:19:37 UTC, Walter Bright wrote:
>> not all interfaces are Objects
>
> Do you have an example? How it can be? Only classes can implement interfaces, and classes inherit from Object.
and I guess even ComObject does not inherit from Object
February 13, 2017
On Monday, 13 February 2017 at 13:21:44 UTC, Daniel Kozak wrote:
> and I guess even ComObject does not inherit from Object

This compiles:
void f()
{
	import core.sys.windows.com;
	ComObject a;
	Object b=a;
}

February 13, 2017
On Monday, 13 February 2017 at 13:38:23 UTC, Kagamin wrote:
> On Monday, 13 February 2017 at 13:21:44 UTC, Daniel Kozak wrote:
>> and I guess even ComObject does not inherit from Object
>
> This compiles:
> void f()
> {
> 	import core.sys.windows.com;
> 	ComObject a;
> 	Object b=a;
> }

"References cannot be upcast to the enclosing class object, nor can they be downcast to a derived interface."

https://dlang.org/spec/interface.html#com-interfaces
February 13, 2017
On Monday, 13 February 2017 at 14:46:38 UTC, Mike Parker wrote:
> "References cannot be upcast to the enclosing class object, nor can they be downcast to a derived interface."
>
> https://dlang.org/spec/interface.html#com-interfaces

COM interfaces can't be downcasted indeed, but it should be possible for D interfaces.
February 14, 2017
On Mon, 13 Feb 2017 15:09:31 +0000, Kagamin wrote:

> On Monday, 13 February 2017 at 14:46:38 UTC, Mike Parker wrote:
>> "References cannot be upcast to the enclosing class object, nor can they be downcast to a derived interface."
>>
>> https://dlang.org/spec/interface.html#com-interfaces
> 
> COM interfaces can't be downcasted indeed, but it should be possible for D interfaces.

But the case that I brought up was cross-casting.

I have an object. It's a D object, which the compiler knows. I don't know if it implements a specific interface, so I cast it. That gives me an expression of the interface type that either refers to the same object or is null.

Except it isn't @safe for some unknown reason.
1 2 3
Next ›   Last »