Gmane
From: Martin Odersky <martin.odersky <at> epfl.ch>
Subject: Re: Runtime types?
Newsgroups: gmane.comp.lang.scala
Date: 2005-11-16 13:34:34 GMT (2 years, 42 weeks, 1 day and 1 hour ago)
> 
> Or alternately things like
> 
>         val foo : List[T]
> 
>         if (foo.isInstanceOf(List[String]]) {
>            // type of foo is refined to be List[String]
>            // without vacuous cast
>         }
> 
The last you can do for monomorphic types with a pattern match:

	val foo: Any;

	foo match {
	  case f: String =>
             // here, f is known to be of type String
         }

But it works for List[String] only if option -Xruntimetypes is given.

In fact, the new version of Scala will have support for GADT's which 
should enable a programming style where type representations can be 
constructed and passed explicitly. Once this works, we will evaluate 
whether or not this can adequately replace runtime types.

Cheers

  -- Martin