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() -> () {..}

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to