Two notes on Eta expansion

Rémi Forax forax at univ-mlv.fr
Sat May 17 06:41:16 PDT 2008


Zdenek Tronicek a écrit :
> 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;
I agree.
Question, is this legal ?

{ Double, Double => Double } p5 = Eta#m2(Double, Double...);

> 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. 
:)
This means the signature of Eta2#m4() is someting like that <T> { => T },
this type exists only internally and can not be used as a type in the code.
I think it's possible to implement that because ForAll already do that.

> Then we could use the following syntax:
>
>     { => String } p5 = Eta2#m4();
>
>
> Z.
R.
> --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