need some clarification on compile-time type vs. run-time type

Yuh-Ruey Chen maian330 at
Fri Nov 9 13:58:48 PST 2007

I've been experimenting with the ES4 RI lately. I've discovered that the
following doesn't work:

x = int;
10 is x;    // error
10 to x;   // error
10 cast x;   // error
var y: x;   // error

Of course, if I had used |type x = int|, it would work. Is this because
x is not a compile-time type? I find it a bit odd that |10 is x| didn't
work while |10 instanceof x| does work, considering that |is| is touted
as the successor to the |instanceof| operator. Or is |instanceof| the
run-time counterpart to |is|? Then should |instanceof| work on
everything that |is| can work on?

These distinctions between compile-time types and these run-time types
(e.g. x in the above example) are subtle and confusing. I figure that
all these distinctions will trip many ES4 newcomers coming from an ES3

BTW, it doesn't seem like the "like" and "wrap" operators are
implemented in the RI yet, so I couldn't really test out structural types.

-Yuh-Ruey Chen

More information about the Es4-discuss mailing list