why is `typeid` only half baked?

Or Dahan via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 9 02:22:03 PST 2015


On Friday, 6 November 2015 at 17:03:38 UTC, Adam D. Ruppe wrote:
> On Friday, 6 November 2015 at 16:38:04 UTC, Or Dahan wrote:
>> [...]
>
> You know, I was about to say no because interfaces can be 
> objects from other languages... but the compiler is strict 
> enough now that it can statically determine if that might be 
> the case.
>
> If the interface derives from IUnknown, it might be a COM 
> object so it can't be sure it is a D class. Similarly if it 
> derives from extern(C++). In those cases, the cast to Object 
> returns null, and attempting to get typeid() off it is liable 
> to outright crash.
>
> But if it is a D interface... it should be ok doing an 
> automatic cast to Object and trying to get typeinfo there.
>
> The only problem it might have is if the typeinfo is in a dll. 
> But I think that has been basically solved too.

So, is it planned to be changed?


More information about the Digitalmars-d mailing list