Type parameters

Nicolas Cannasse ncannasse at motion-twin.com
Wed Sep 6 05:47:17 PDT 2006


> I wrote my example badly. I was trying to understand how parametrised
> types are treated. That is, is each parametrisation a proper type,
> having it's static code run once per parametrisation, or is static
> code run once when the definition is imported?
> 
> e.g.
> 
> 
>   class Example.<A> {
>        {
>             print("hello");
>        }
>   }
> 
>   eStr = new Example.<String>();
>   eObj = new Example.<Object>();
> 
> 
> Should I expect "hello" to be output once or twice?

Only one. Either the VM supports type parameters, then it will only have
one class instance, or it simply "forget them" after compiling, and
insert runtime casts in the generated bytecode (like Java 1.5 Generics).

Nicolas




More information about the Es4-discuss mailing list