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

Chris Lattner clattner at apple.com
Fri Apr 15 12:39:40 CDT 2016


On Apr 15, 2016, at 12:47 AM, Andrey Tarantsov <andrey at tarantsov.com> wrote:
> Chris,
> 
>> 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) -> ()
> 
> I don't care about this particular question too much, although I still prefer less parenthesis where possible.
> 
> But I fear that going this way, we'll soon arrive at requiring parenthesis for the block arguments:
> 
> do_something { foo in 
>   ...
> }
> 
> and that (the parenthesis in blocks) is something I would love to avoid.

I see your concern, and while someone might propose that, I would be pretty strongly against it.  The closure parameter syntax is already magical in many ways (e.g. you can elide the "-> ReturnType” before in, so I don’t see a reason to mechanically force alignment with type syntax.  Further, closures are written much more often than function types, so terseness is a lot more beneficial.

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160415/97c83036/attachment.html>


More information about the swift-evolution mailing list