[swift-evolution] [pitch] Eliminate the "T1 -> T2" syntax, require "(T1) -> T2"
Vladimir.S
svabox at gmail.com
Fri Apr 22 17:43:16 CDT 2016
On 23.04.2016 0:52, Антон Жилин wrote:
> We can disallow putting types in parentheses in single-element tuple meaning.
> For example, (Int) -> (Double) will be illegal because of (Double).
> (Int) -> (Double) -> Bool will be legal, because parentheses mean function
> type here.
> (Int) -> () will be legal, because () means Void here.
> This can be theme of a separate proposal.
Just to clarify the proposal:
1. Disallow putting types in parentheses in single-element tuple meaning
wrong : (Int) -> (Double)
correct: (Int) -> Double
wrong: (Int) -> (Double) -> (Bool)
correct: (Int) -> (Double) -> Bool
* this rule also affects Void:
wrong: (Int) -> (Void)
correct: (Int) -> Void
wrong: (Int) -> (Double) -> (Void)
correct: (Int) -> (Double) -> Void
but correct: (Int) -> (Void) -> Void
2. Where it is allowed to have (Void) as parameters declaration, disallow
putting (Void) in parentheses
wrong: (Int) -> ((Void)) -> Int
correct: (Int) -> (Void) -> Int
3. Disallow putting empty tuple () in parentheses
wrong: ((())) -> Int
correct: () -> Int
wrong: () -> ((()))
correct: () -> ()
Correct?
>
> - Anton
>
> On 22.04.16, Vladimir.S wrote:
>
> What I really don't like is that we can have all this:
> func f1() -> (Void) {..}
> func f2(Void) -> ((Void)) {..}
> func f3() -> (((()))) {..}
> func f4(((Void))) -> (Void) {..}
> func f5() -> ((Void)) {..}
> func f6((())) -> (((()))) {..}
> and all is equivalent for
> func f() -> () {..}
>
More information about the swift-evolution
mailing list