Optional brackets around lambda expression

Steven Simpson ss at comp.lancs.ac.uk
Fri Jun 17 23:45:31 PDT 2011


On 18/06/11 04:33, Ali Ebrahimi wrote:
> seperate syntax for expresion lambdas and statement lambdas :

Thought I'd try to distill it, but I might have introduced things you
didn't intend:

  Lambda = *1LambdaParamListOrParam "->" LambdaBody

  LambdaParamListOrParam = LambdaParamList | LambdaParam

  LambdaParamList = "(" 1#LambdaParam ")"

  LambdaParam = FormalParameter | Identifier

  LambdaBody = Expression | Block

Lots of *LWS implied.  I think using 'Expression' will make the lambda
greedy, right?

This grammar permits partial type inference, e.g. (x, Foo y) -> x + y. 
Is there any problem with that?

In the unary case, I've permitted the parameter to have a type, e.g. Foo
x -> x.  Does that cause problems if the type includes generics, e.g.
process(a, b, c, Foo<Bar> x -> x)?  If so, only permit an identifier in
the unary case.



More information about the lambda-dev mailing list