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

Sean Heber sean at fifthace.com
Tue Apr 19 09:59:19 CDT 2016

For what it’s worth, I searched my Swift code and didn’t find a single instance where I did *not* use the parens - even for single-argument functions. Until this conversation came up, I don’t recall if it ever even occurred to me that I *could* leave the parentheses out!


> On Apr 19, 2016, at 9:49 AM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>> On Apr 18, 2016, at 4:31 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>> on Fri Apr 15 2016, Brent Royal-Gordon <swift-evolution at swift.org> wrote:
>>>> 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?
>>> While it's technically correct, I agree with John's assessment that
>>> this is "fussy". `T -> U` doesn't confuse people 
>> Do we have any data on this (in either direction)?
>> Personally, it has always seemed obvious that T -> U being a function
>> type would be quite novel to some people, considering the number of
>> times I've seen in Haskell texts that (surprise!) you don't need
>> parentheses to invoke functions.  I guess those are invocations and
>> we're talking about declarations here, but declaration-follows-use is a
>> kind of principle the language tries to uphold.
>> But that's just intuition.  Data would be very interesting.
> Apart from intuition and confusion, parentheses are used at call sites
> and declarations. It seems out of line that they can be removed in types 
> but only in one degenerate case.
> This goes against the Swift core design goal of consistency.
> -- E
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list