typeid() broken for interfaces?

Jacob Carlborg doob at me.com
Tue Dec 4 04:29:30 PST 2012


On 2012-12-04 13:15, foobar wrote:

> IMO this is a design mistake - the special case is preferred over the
> common case which goes against the D philosophy of making the common
> case easy and the special case possible.
>
> All COM instances are known at _compile_time_ as they're all required to
> inherit from a special IUnknown interface so the compiler _knows_ if
> indeed an interface represents a COM instance or not. This can be used
> to handle this special case differently.
>
> Interface i = new Class();
> Object o = i; // should work for regular interfaces
>
> The compiler can issue a compile-time error if i is COM since this is
> known at compile type.

Exactly, I couldn't agree more.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list