fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

language improvement: implicit call after parentheses

Open fridis opened this issue 3 years ago • 1 comments

We can call a function that is the result of an expression in paranthesis explicitly:

 > echo "(x).call 7; x i32->unit is v -> say v" | ./build/bin/fz -
7

would be nice to not require the .call as in

 > echo "(x) 7; x i32->unit is v -> say v" | ./build/bin/fz -

-:1:5: error 1: Syntax error: expected semicolon ';', found numeric literal '7'
(x) 7; x i32->unit is v -> say v
----^
While parsing: semicolon or flat line break, parse stack: semiOrFlatLF, stmnts, unit

one error.

fridis avatar Feb 09 '22 15:02 fridis

This works:

echo "x 7; x i32->unit => v -> say v" | ./build/bin/fz -

and i would argue that it is maybe better that this does not work

echo "(x) 7; x i32->unit => v -> say v" | ./build/bin/fz -

michaellilltokiwa avatar Mar 04 '25 10:03 michaellilltokiwa

I think we should drop this, (expr) arg1 arg2 should not be syntax sugar for (expr).call arg1 arg2.

fridis avatar May 27 '25 14:05 fridis