A syntax option (function types versus arrays)

Peter Levart peter.levart at marand.si
Tue Mar 2 00:10:04 PST 2010


On Tuesday 02 March 2010 01:05:32 Mark Mahieu wrote:
> 
> On 1 Mar 2010, at 23:42, Neal Gafter wrote:
> > 
> > I agree with Rémi that you don't need so many parens.  You could put
> > the throws either before or after the result type.  I'd also suggest
> > keeping the lambda and function type syntax forms parallel in part
> > because the lambda is the primary, and currently only, way to get a
> > value of function type.  For example either
> > 
> >    (String -> int throws SomeException) variable = (String x -> 3);
> > 
> > or, as Rémi suggests
> > 
> >    (String throws SomeException -> int) variable = (String x -> 3);
> > 
> > So the curry example would be something like
> > 
> >    static <T,U,V,X extends Throwable>
> >    (T->(U throws X->V)) curry((T,U throws X->V) function) {
> >        return (T t->(U u->function.(t,u)));
> >    }
> > 
> > Cheers,
> > Neal
> > 
> 
> That's pretty good in my eyes - for these non-trivial types I think it's much easier to follow than the equivalent code using the currently proposed syntax.
> 
> It's easy to see where each function type or lambda begins and ends (and editors/IDEs will be able to offer matching bracket highlighting as they do elsewhere in the language).
> 
> Mark
>

I also think that it is good that this syntax doesn't abuse '#' for yet another thing. There's already non-java identifiers and method references that use it. Adding function types and lambdas to the mix increases confusion as everything looks similar.

Peter


More information about the lambda-dev mailing list