Skip to content

Instantly share code, notes, and snippets.

@waneck
Created July 26, 2012 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waneck/3182194 to your computer and use it in GitHub Desktop.
Save waneck/3182194 to your computer and use it in GitHub Desktop.
@:generic proposal, 2
@:generic class Array<T>
{
private var arr:NativeArrayWrapper<T>;
public function new()
{
arr = new NativeArrayWrapper<T>(0); // this will be automatically replaced
}
public function get(x:Int):T
{
return arr.get(x);
}
}
//this will be transformed into:
@:generic class Array<T>
{
private var arr:NativeArrayWrapper<T>;
public function new(cl:Class<T>)
{
arr = NativeArrayWrapper.alloc(cl, 0);
}
public function get(x:Int):T
{
return arr.get(x);
}
public function get_f(x:Int):Float
{
return arr.get_f(x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment