Optional brackets around lambda expression: proposed syntax with full grammar

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Sat Jun 18 02:22:35 PDT 2011


Hi all,

This is full grammar of my proposed syntax:

LambdaDeclaration =
                    LambdaParameterList '->' LambdaBody

LambdaParameterList =
	ZeroOrOneLenParameterList | GreaterThanOneLenParameterList

ZeroOrOneLenParameterList =
	('(')? LambdaParameter? (')')?

GreaterThanOneParameterList=
	'(' LambdaParameter , (LambdaParameter)+ ')'

LambdaParameter =
	Parameter | Identifier

LambdaBody =
	Expression | `{' Statement* `}'
	

Best Regards
Ali Ebrahimi
On 6/18/11, Steven Simpson <ss at comp.lancs.ac.uk> wrote:
> 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