[swift-evolution] Proposal: Always flatten the single element tuple

Vladimir.S svabox at gmail.com
Thu Jun 8 08:01:40 CDT 2017


On 08.06.2017 12:17, Víctor Pimentel Rodríguez via swift-evolution wrote:
> On Thu, Jun 8, 2017 at 5:15 AM, Susan Cheng via swift-evolution 
> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>     Just a thought
> 
>     if parentheses is important, why the tuples are not?
> 
> 
> This is stated on the proposal (and not in previous proposals):
> 
> https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md
> 
>   *
> 
>     We understand that this may be a departure from the current convention that a set
>     of parentheses enclosing a single object are considered semantically meaningless,
>     but it is the most natural way to differentiate between the two situations
>     described above and would be a clearly-delineated one-time-only exception.
> 
> 
>     <https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md#impact-on-existing-code>
> 
> This proposal marks a one-time-only exception, to differentiate the parenthesis 
> needed to enclose a list of closure parameters and the parenthesis needed for tuples. 
> That's adding an exception for implementing a regression.
> 
> The more I think about it, the more I hate* this proposal.
> 
> * Well, not _hate_, let's say slightly dislike :P

Please look here:
https://github.com/apple/swift-evolution/blob/master/proposals/0066-standardize-function-type-syntax.md

into "Proposed solution" section:

Parentheses will be required in function types. Examples:

Int -> Int           // error
(Int) -> Int         // function from Int to Int
((Int)) -> Int       // also function from Int to Int

Int, Int -> Int      // error
(Int, Int) -> Int    // function from Int and Int to Int
((Int, Int)) -> Int  // function from tuple (Int, Int) to Int

let f: () -> Int     // function with no parameters
let g: (()) -> Int   // function taking a single () parameter
let h: ((())) -> Int // function taking a single () parameter

f();   g(()); h(())  // correct
f(()); g();   h()    // errors

Do you also hate* SE-0066?

> 
> -- 
> Víctor Pimentel
> 
> 
> _______________________________________________
> 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