Is it possible to use Haxe parameterized types in ActionScript?
Is there any way I can use a parameterized Haxe type like this:
class GenericTest<T> {
public fu开发者_开发问答nction putSomething(value:T) {
...
}
public function getSomething():T {
...
}
}
in ActionScript?
var o:GenericTest.<int> = new GenericTest.<int>();
I tried building to a .swc
and including that but the type parameters turn to plain Objects. It seems like there must be a way to trick flash into using custom generic types if the support exists for Vector
. Or is that a special case built into the player?
Nevermind, it looks impossible without compiler modifications according to these two posts:
- http://www.davidarno.org/2011/04/19/as3-user-defined-generics-why-they-are-not-possible-yet/
- http://alecmce.com/as3/why-we-need-generics-in-as3
That's disappointing but I can't say I didn't expect it.
精彩评论