[swift-evolution] [Proposal draft] Generalized Naming for Any Function
Michel Fortin
michel.fortin at michelf.ca
Sun Dec 27 19:11:31 CST 2015
Le 27 déc. 2015 à 19:54, Wallacy via swift-evolution <swift-evolution at swift.org> a écrit :
> Even with backticks would not be possible.
>
> You may need to reference the method signature altogether.
>
> var someA = A()
> let fn1 = someA.#someFunc(a: Int) -> Int
> let fn2 = someA.#someFunc(a: Int) -> Double
> let fn3 = someA.#someFunc(a: Double) -> Int
> let fn4 = someA.#someFunc(a: Double) -> Double
>
> An operator at the beginning perhaps?
>
> let fn1 = #someA.someFunc(a: Int) -> Int
> let fn2 = #someA.someFunc(a: Int) -> Double
> let fn3 = #someA.someFunc(a: Double) -> Int
> let fn4 = #someA.someFunc(a: Double) -> Double
Well, this works today:
let fn1: Int -> Int = someA.someFunc
let fn2: Int -> Double = someA.someFunc
let fn3: Double -> Int = someA.someFunc
let fn4: Double -> Double = someA.someFunc
In fact, this too works:
let fn1: (a: Int) -> Int = someA.someFunc
let fn2: (a: Int) -> Double = someA.someFunc
let fn3: (a: Double) -> Int = someA.someFunc
let fn4: (a: Double) -> Double = someA.someFunc
See the parameter name in the type? It could be used to disambiguate, but currently it is not taken into account: if you add a `someFunc` overload taking a different parameter name but the same types the above code becomes ambiguous.
--
Michel Fortin
https://michelf.ca
More information about the swift-evolution
mailing list