2013/7/18 Mark Thomas wrote:
>
> On 18/07/2013 08:00, Violeta Georgieva wrote:
> > Hi,
> >
> > Let's have a lambda expression:
> >
> > x->y->x-y
> >
> > Let's now assign it and invoke it indirectly:
> >
> > f = x->y->x-y; f(2)(1)
>
> Several problems here.
>
> 1. The grammar didn't support functions having multiple sets of
parameters.
>
> 2. The lambda expression handling in AstFunction only handled single
> parameters sets.
>
> 3. The incMethodParameterIndex() can't be used in this case so an
> alternative solution is required to the problem that addressed.
>
> All of these have been fixed in trunk. There is some more clean-up that
> can now be done.
>
> I look forward to your next brain teaser :)
>

;)

If I modify the example above like this

f = ()->y->2-y; f()(1)

Then I'm receiving an exception:

javax.el.ELException: Only [0] arguments were provided for a lambda
expression that requires at least [1]
at javax.el.LambdaExpression.invoke(LambdaExpression.java:60)
at javax.el.LambdaExpression.invoke(LambdaExpression.java:92)
at org.apache.el.parser.AstFunction.getValue(AstFunction.java:103)
at org.apache.el.parser.AstSemicolon.getValue(AstSemicolon.java:37)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188)
at javax.el.ELProcessor.getValue(ELProcessor.java:45)

Reply via email to