HaxeFoundation / HaxeFoundation/haxe
`ArrayAccess<T>` can't be used as a type constraint
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
I'm fully aware that `ArrayAccess` is a "special" interface used to allow array access on class types, however I think it should be able to be used as a type constraint at compile-time.
As an example here's a method from one of the typed arrays in `js.lib`:
```hx
@:overload(function(array:Int8Array, ?offset:Int):Void {})
@:overload(function(array:Uint8Array, ?offset:Int):Void {})
@:overload(function(array:Uint8ClampedArray, ?offset:Int):Void {})
@:overload(function(array:Int16Array, ?offset:Int):Void {})
@:overload(function(array:Uint16Array, ?offset:Int):Void {})
@:overload(function(array:Int32Array, ?offset:Int):Void {})
@:overload(function(array:Uint32Array, ?offset:Int):Void {})
@:overload(function(array:Float32Array, ?offset:Int):Void {})
@:overload(function(array:Float64Array, ?offset:Int):Void {})
function set(array:Array, ?offset:Int):Void;
```
if `ArrayAccess` could be used as a constraint, it could be turned into:
```hx
@:overload(function>(array:T, ?offset:Int):Void {})
function set>(array:T, ?offset:Int):Void;
```
Contributor guide
Assessment
This issue has not been assessed yet.