On Mon, May 8, 2017 at 12:16 AM, David Hart <da...@hartbit.com> wrote:

>
> On 7 May 2017, at 00:21, Xiaodi Wu via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> To which human would it be misleading?
>
> To the writer? No, because the compiler will warn you right away. By the
> time you're done with writing the first line, it'll warn you that Int and
> Double are unused variables. And if you try to use x and y, you get an
> error.
>
> To the reader? Only if the writer knowingly wrote this misleading code. In
> other words, it's a nice puzzle, but no reader will encounter this in
> real-world code, unless they're being tormented by the writer on purpose.
>
>
> IMHO, the fact that the compiler warns you does no change the fact that
> it's a very confusing part of the language. It should not be an excuse for
> fixing it. Consistency teaches us to expect a type after a colon.
>

Highly disagree. Consistency teaches us that variables can come after a
colon.

```
func foo(bar: Int, baz: Int) {
  print(bar, baz)
}

func foo(bar: Bool, baz: Bool) {
  print(bar, baz)
}

let x = 42
let y = 43
foo(bar: x, baz: y)
// x and y are variables, and they come after the colon.
// We don't allow users to write `foo(bar x: Int, baz y: Int)`,
// even when there are overloads.
```

There is nothing inconsistent about this part of the language.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to