[haXe] Q: Class with type parameter, instance variable

Ian Liu ian.liu88 at gmail.com
Wed Jul 4 19:23:17 CEST 2007


I think this class parameter only works for instances of the class. The
static variable is resolved independently of any instantiation, so no
parameter is passed to it.


On 7/4/07, Zjnue Brzavi <zjnue.brzavi at googlemail.com> wrote:
>
> Hi list,
>
> I'm having trouble understanding why the following will not compile.
>
> class ABase<I> {
>         public function new () {
>         }
>         public function execute( c : I ) {
>                 c.doSomething();
>         }
> }
>
> class A<I> extends ABase<I> {
>
>         private static var inst :A<I>; //A.hx:3: characters 16-31 : Class
> not found : I
>
>         public function new() {
>                 super();
>         }
>         public static function main () {
>                 inst = new A<IA>();
>         }
> }
>
> interface IA {
>         public function doSomething();
> }
>
> Should the instance variable of class A not be accessible
> through A<IA>.inst
> ?
>
> Any explanations would be fantastic!
>
> Zjnue
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070704/8c5276f8/attachment.htm


More information about the Haxe mailing list