Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Won't Fix
-
Affects Version/s: X10 2.0.4
-
Fix Version/s: None
-
Component/s: Language Design
-
Labels:None
Description
public interface AO[T] { public operator + this: T; public operator - this: T; public operator this + (that: T): T; public operator this - (that: T): T; public operator this * (that: T): T; public operator this / (that: T): T; public operator this % (that: T): T; } class A[T] implements (Int)=>T { val t:T; public def apply(int):T = t; def sum() {T <: AO[T]} { var s:T = 0 as T; // generic additive identity s += this(0); // generic addition return s; } def this(t:T) { this.t = t; } } public class Bug { public static def main(args:Rail[String]) { val a = new A[Int](1); System.out.println("a.sum() " + a.sum()); } }
This attempt doesn't work because
- the primitive types don't declare that they implement +, etc. and
- there's no notion of a generic additive identity - seems like this might be a static field of the primitive types, but we can't access static fields of type parameters...
Or is there some other way to do this that I'm missing?
Issue Links
- is depended upon by
-
XTENLANG-962
Array library redesign
-
Affects
Array/TestSimpleArrayMult
Array/IntArrayMaxAbs