A syntax option (function types versus arrays)
Peter Levart
peter.levart at marand.si
Tue Mar 2 04:00:07 PST 2010
On Tuesday 02 March 2010 00:42:26 Neal Gafter wrote:
> > So can you comment on further grammar changes to allow
> > parentheses round the function type:
> >
> > ((A throws X)->Y)[] y; // Array of function-typed values
>
> 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
What about casts? Double parens? Is it possible, fom syntax perspective, that for function types the cast would simply state a function type without additional parens?
CastExpression:
( ReferenceTypeNoFunctionType ) UnaryExpressionNotPlusMinus
FunctionType UnaryExpressionNotPlusMinus
Regards, Peter
More information about the lambda-dev
mailing list