Hi Yan Li --- What you are asking for can be done with existential types or wildcards.
However you can circumvent this problem by defining an appropriate class. class Finish[T] { var x:T; public this(t:T) { x=t;} // replacement for startFinish public stopFinish():T { return x; } } So now for every finish of type T you would write: var finish = new Finish[T](r); .... val t = finish.stopFinish(); Yan CRL Li wrote: > My problem is : I want to share a variable of generic class T between two > static functions: > > Pseudo Code : > > var X:T; > > Function A: > public static def startFinishExpr[T] (r:T): Void { > // set X = r. > } > > Function B: > public static def stopFinishExpr[T]():T {): > // get X; > return X;; > } > > Both of these two functions need to acces one variable named X which is of > generic class. > > I know how to do this if it is not generic class. I can create another > final static class B whose member is X. Then I can new one instance of this > class B and modify X through set and get method. However, this not work if > it is generic. As I can not new one instance of class B if I do not know > its type T. I only know what T is when function A is called. > > Can anyone give some suggestions? > > Thanks in advance. > > Li Yan (李严) > > System Group, IBM China Research Lab > Tel: 8610-58748060 > Tieline: 11905-8060 > Add: Building 19 Zhongguancun Software Park, 8 Dongbeiwang WestRoad, > Haidian District, Beijing, 100094, P.R.China > E-mail: liyan...@cn.ibm.com > ------------------------------------------------------------------------------ > _______________________________________________ > X10-users mailing list > X10-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/x10-users > ------------------------------------------------------------------------------ _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users