Parentheses are optional for dot notation with no arguments
Fuzion call syntax
The following tables show what is currently considered for Fuzion:
Call with and without parentheses
Fuzion
Haskell
Java
Comment
a(b,c,d)
a b c d
a(b,c,d)
Fuzion should support classic call syntax.
a b,c,d
a b c d
a(b,c,d)
Parentheses should be optional.
a b c d
a b c d
a(b,c,d)
Commas should be optional.
a b,c d
a b (c d)
a(b,c(d))
Commas, if present, must be used to separate all arguments,
Examples
Binding strength of calls and prefix/postfix operators:
Fuzion
Haskell
Java
Comment
f -1
f (-1)
f(-1)
Raku-style: infix or postfix operators bind stronger if there is no
space between the operator and its operand.
f - 1
f - 1
f - 1
With spaces, we get an infix oparator, so this is equivalent to f.infix -(1).
f-1
f - 1
f - 1
Without any spaces, we also get an infix oparator, so this is equivalent to f.infix -(1).
f x-1
f (x-1)
f(x-1)
Extended Raku-style: infix operators without space bind stronger than calls!
f x - 1
f x - 1
f(x) - 1
Extended Raku-style: infix operators with space bind weaker than calls!
f x -1
f x (-1)
f(x, -1)
Raku-style: prefix operators without space bind stronger than calls!
f x- 1
f (x-) 1
f(x.postFixMinus(), 1)
Raku-style: postfix operators without space bind stronger than
calls, so this is equivalent to f(x.postfix -, 1).
Examples
Calls with parentheses:
Fuzion
Haskell
Java
Comment
f(a b c)
f (a b c)
f(a(b, c))
Parentheses may go around all arguments and commas can be omitted, turning this into f(a(b, c)).
f(a, b, c)
(f a b c)
f(a, b, c)
Parentheses may go around all arguments, requiring commas to avoid
turning argument list into a call. So this is equivalent to f a b
c.
(f a b c)
(f a b c)
f(a,b,c)
Parentheses may go around a call
Examples
Binding strength of calls and infix operators:
Fuzion
Haskell
Java
Comment
a b * c d
a b * c d
a(b)*c(d)
Call has highest precedence, so this is equivalent to a(b) * c(d).
a b*c d
a (b * c) d
a(b*c, d)
infix operator without spaces has higher precedence than call. so this
is equivalent to a(b*c,d).
Examples
Function Composition
Fuzion
Haskell
Java
Comment
f g x
f g x
f(g, x)
Even if f, g are both functions, g is not called here, but passed as
argument to f. Function call binds to the left.
f(g x)
f (g x)
f(g(x))
Parentheses are required to pass the result of applying g to x to f.
NYI: Compose operator
(f . g) x)
int fg(int y) { return f(g(y)); }
fg(x);
Function composition via a dedicated operator is currently not
supported. Need compelling use cases to justify this, could be realized
with syntactic sugar.
Examples
Currying
Fuzion
Haskell
Java
Comment
f(i32 x, y) => x + y*y
g => f 3 # NYI! Currying
g 4
f x y = x + y*y
g = f 3
g 4
int f(int x, y) { return x + y*y; }
int g(int y) { return f(3, y); }
g(4);
NYI: Currying: Applying only a part of the arguments to a function results
in a function that expects the remaining arguments.
Examples
Tuples as arguments
Fuzion
Haskell
Java
Comment
f((a, b))
f (a, b)
record Tuple(int v, int w) { }
f(new Tuple(a, b))
Passing a tuple in Fuzion requires double-parentheses to disambiguate
passing a tuple from a call using parentheses.
f (a, b)
f (a, b)
record Tuple(int v, int w) { }
f(new Tuple(a, b))
Separating the argument from the name of the called feature turns the
argument into a tuple.
Examples
Object-oriented style calls
Fuzion
Haskell
Java
Comment
obj.m x
--
obj.m(x)
Object-oriented dot notation for a call. Here, the scope to
lookup m is different, m is searched for in the visible
features of the static type of obj only.
obj m x # not supported! useful?
--
obj.m(x)
Scala-like operator notation for a call. This would result in an
ambiguity if m exists both in the local scope and in the static
type of obj. Which m should be taken in this case?
m obj x # not supported! useful?
--
obj.m(x)
Nim-style call syntax for object-oriented calls. If f64
declares sin, this would permit code like sin α for
a f64 value α instead of α.sin. Does this justify
extending the call syntax? An alternative with the same effect would be
to declare sin within a different unit-type feature trigo
and then either use trigo.sin α or to inherit trigo to
make sin visible such that a call sin α is possible.
Examples
Type parameters
myMap<i32,string>
?
myMap<i32,string>()
Type parameters are enclosed in angle brackets like in Java.
myMap i32 string # NYI!
?
myMap<i32,string>()
NYI: Syntax for type parameters should be the same as for value parameters.