f(a T, b T->T) => b a
x := 42
y := f x v->2*v
say y
works
> ./build/bin/fz test_lambda.fz
84
but using parentheses and commas in the call to f(x, v->2*v) as follows
f(a T, b T->T) => b a
x := 42
y := f(x, v->2*v)
say y
produces an error
> ./build/bin/fz test_lambda2.fz
/home/fridi/fuzion/work/test_lambda2.fz:4:6: error 1: Different count of arguments needed when calling feature
y := f(x, v->2*v)
Feature not found: 'f' (one argument)
Target feature: 'universe'
In call: 'f(x, v->2*v)'
To solve this, you might change the actual number of arguments to match the feature 'f' (2 arguments) at /home/fridi/fuzion/work/test_lambda2.fz:1:1:
f(a T, b T->T) => b a
one error.
This can currently be solved by adding more parentheses f(x, (v->2*v))
f(a T, b T->T) => b a
x := 42
y := f(x, (v->2*v))
say y
which works
> ./build/bin/fz test_lambda3.fz
84
I think it might be better to change the parser to parse f(x, v->2*v) as a call with two arguments x and v->2*v and require parentheses if one wants it to be parsed as a binary lambda f((x, v)->2*v).
This
works
but using parentheses and commas in the call to
f(x, v->2*v)
as followsproduces an error
This can currently be solved by adding more parentheses
f(x, (v->2*v))
which works
I think it might be better to change the parser to parse
f(x, v->2*v)
as a call with two argumentsx
andv->2*v
and require parentheses if one wants it to be parsed as a binary lambdaf((x, v)->2*v)
.