On Friday, 21 November 2014 at 22:30:52 UTC, Eric wrote:
On Friday, 21 November 2014 at 22:25:32 UTC, anonymous wrote:
On Friday, 21 November 2014 at 22:15:37 UTC, Eric wrote:
[...]
class X { }
class Y : X { }

Y y = new Y;

X x = y;
[...]
I have't quite mastered the whole is/typeof/typeid
thing yet.

Maybe this helps:

There are two worlds:
* the static world = the compile time world = the world of types
and constant values,
* the dynamic = the run time world = the world of values.

Obviously, there are no variable values in the static world.
Maybe less obviously, there are no types in the dynamic world.

The variable x is statically typed as X. is(...) and typeof(...)
operate on this level. But the object stored in x is being
constructed as a Y at run time. That information is available
through typeid.

typeid(...) is not a type, it's a value of type TypeInfo which
corresponds to a type. typeid(Y) and typeid(x) are TypeInfo
objects both corresponding to the type Y.

Reply via email to