Summary: Function type syntax

Tom Hawtin Thomas.Hawtin at Sun.COM
Sun Mar 14 13:40:04 PDT 2010


Stephen Colebourne wrote:
> (Extracting Stefan's list and enhancing)
> 
> [...]

> 15) Lightweight interfaces, 19 Feb 2010
>   interface Name ReturnType ( TypeList ) throws ExceptionList;
>   interface Counter int();

Oh, it's a counter. I got this far and I didn't know what it was 
supposed to be.

>   interface Reader String(File) throws IOException;

Not a display name for the file then?

>   interface CurryBase<R, E, throws E> R(A) throws E
                            ^A                        ^; ?
>   interface CurryResult<R, throws E> R() throws E
>   interface Curry<R, A, throws E> CurryResult<R. E>( CurryBase<R, A, E>, A )
                                                  ^,
I'm not sure the curry example is that useful. The idea is to use 
meaningful types? But at least it is understandable, with some effort.

I don't understand the allergy to names. It would be nice to be able to 
refer to the arguments. Put in names, and there is no need to add to the 
method call syntax.

For comparison, here's how it is in existing Java with just "throws" added:

   interface Name {
     ReturnType MethodId ( FormalParameterDecls ) throws ExceptionList;
   }
   interface Counter { int next(); }
   interface Reader { String read(File file) throws IOException; }
   interface CurryOp<R, A, throws E> { R op(A arg) throws E; }
   interface CurryCall<R, throws E> { R call() throws E; }
   interface Curry<R, A, throws E> {
     CurryOp<R, E> apply(CurryCall<R, A, E> op, A arg);
   }

That's not so bad declaration side.

Tom


More information about the lambda-dev mailing list