By adopting a syntax like
fn add(x: i32, i32) i32
they have said perma-goodbye to lambdas. They should have at-least considered fn add(x: i32, i32): i32
They could still fix it with arrow functions, but it’s always gonna look weird.
Some other people have tried to explain how they prefer types before variable declarations, and they’ve done a decent job of it, but it’s the function return type being buried that bothers me the most. Since I read method signatures far more often than method bodies.
fn i32 add(…) is always going to scan better to me.
Why “perma goodbye”?
Go has a similar function declaration, and it supports anonymous functions/lambdas.
E.g. in go, an anonymous func like this could be defined as
foo := func(x int, _ int) int { … }
So I’d imagine in Zig it should be feasible to do something like
var foo = fn(x: i32, i32) i32 { … }
unless I’m missing something?