I'm trying to get my head around the philosophy of Swift in the area of what is considered too terse. Looking at this feature in C#, which is also making its way to Java, I'm wondering if it would be out of step with Swift's principles?
Swift already allows "expression bodied" closures, where if you write something like map { $0 + 1 } the expression is implicitly returned. It would seem consistent to me to allow this for all function bodies, so that you could leave out the return if the body consists of a single expression:
Swift has some other syntactic shortcuts that would unfortunately make the C#/Java style shorthand ambiguous in some cases (particularly with accessors in properties), but the brace approach should work and is consistent with another part of the language today.
It seems that there are two asks in place. One is an ability to define functions as single expressions. Another ask is to implicitly pass function arguments into the expression in case if inputs & outputs of an expression matching function signature, so the following can be possible.
func makeBFromA(a: A) -> B = aToB
func aToB(a: A) -> B { ... }
I didn't know this is a thing in C#, but definitely common in Haskell and allows to reduce a boilerplate without sacrificing readability. Is something like this potentially can be accommodated by Swift too?
I don't know the technical reasons, but my proposal wasn't even allowed to go into review back then, and I would like to link this comment from @Chris_Lattner3: