[swift-evolution] [pitch] Eliminate the "T1 -> T2" syntax, require "(T1) -> T2"

Erica Sadun erica at ericasadun.com
Fri Apr 15 00:05:22 CDT 2016

> On Apr 14, 2016, at 10:57 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> We currently accept function type syntax without parentheses, like:
>  Int -> Float
>  String -> ()
> etc.  The original rationale aligned with the fact that we wanted to treat all functions as taking a single parameter (which was often of tuple type) and producing a tuple value (which was sometimes a tuple, in the case of void and multiple return values).  However, we’ve long since moved on from that early design point: there are a number of things that you can only do in a parameter list now (varargs, default args, etc), implicit tuple splat has been removed, and  the compiler has long ago stopped modeling function parameters this way.  Beyond that, it eliminates one potential style war.
> Given all this, I think it makes sense to go for syntactic uniformity between parameter list and function types, and just require parenthesis on the argument list.  The types above can be trivially written as:
>  (Int) -> Float
>  (String) -> ()
> Thoughts?

Didn't know that T -> U was even legal, which more or less sums up my opinion on this. 

Does it meet Swift's philosophy? Yes
Does it enhance the language? I believe it does
Is it still required in a post-splatted world? Probably not
Eliminating a language inconsistency, especially a meaningless one? Yes.

-- E, unless I'm missing something big here

More information about the swift-evolution mailing list