[Pitch] Make `default` function parameter values more transparent


(Anton Zhilin) #1

-1 to default parameters in protocols.

Default parameters fall into a bad category of function features.
Since I'm bad at explaining things, I'll give an example.

protocol A {
    func call(block: @autoclosure () -> ())
}
protocol B {
    func call(block: () -> ())
}

Now it's impossible to conform to both of these protocols.

@noescape is good, because we can conform to both protocols with a
@noescape function.
`throws` is good, because we can conform to both protocols with a
non-throwing function.

On the other hand, consider a case with defaulted parameters:

protocol A {
    func foo(x: Int = 1)
}
protocol B {
    func foo(x: Int = 2)
}

It's impossible to conform to both protocols at once.
Therefore, default parameters is together with @autoclosure and on the
opposite side of @noescape and `throws`. That is, on "ambiguous" side.
I would prefer to have as few such features as possible.

- Anton