Two notes on Eta expansion

Zdenek Tronicek tronicek at fel.cvut.cz
Sat May 17 05:54:55 PDT 2008


Hi,

just two notes:

1) when we refer to a method with variable-length argument list, we  
have to use array:

     static <T> T m2(T t, T... next) {
         T s = t;
         for (T i :  next) {
             s = i;
         }
         return s;
     }

     public static void main(String[] args) throws Exception {
         // p3 must have always two arguments
         { Double, Double => Double } p3 = Eta#m2(Double, Double);
         // p4
         { Double, Double[] => Double } p4 = Eta#m2(Double, Double[]);

     }

It would be nice if we may use e.g. { Double, Double... => Double } p4;

2) when we refer to a generic method, e.g.

     static <T> T m4() { return null; }

     { => String } p5 = Eta2#<String>m4();

    it would be nice if the type parameter is inferred. Then we could  
use the following syntax:

     { => String } p5 = Eta2#m4();


Z.
-- 
Zdenek Tronicek
Department of Computer Science and Engineering
Prague                   tel: +420 2 2435 7410
http://cs.felk.cvut.cz/~tronicek






More information about the closures-dev mailing list