Support for recursive type bounds
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
It would be nice to support recursive type bounds.
I was trying to do something like the following:
```swift
interface Vector {
subVectors(a :VT, b :VT) :VT;
}
class VecRange> {
create() :VectorT {
throw new Error("abstract");
}
constructor(min :VectorT, max :VectorT) {
this.gamut = this.create().subVectors(max, min);
}
}
```
but such fanciness appears not to be supported. This sort of thing is quite common in Java &c where you might do something like:
```java
interface Vector {
public VT sub (VT a, VT b);
}
abstract class VecRange> {
public abstract VectorT create();
public VectorT gamut (VectorT max, VectorT min) {
return this.create().sub(max, min);
}
}
class Vector3 implements Vector {
public Vector3 sub (Vector3 a, Vector3 b) { return null; /*stub*/ }
}
class VecRange3 extends VecRange {
public Vector3 create() {
return new Vector3();
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.