[swift-evolution] [Proposal draft] Generalized Naming for Any Function

Wallacy wallacyf at gmail.com
Sun Dec 27 19:19:21 CST 2015


*"if you add a `someFunc` overload taking a different parameter name but
the same types the above code becomes ambiguous."*

Yes, I know, I forgot this example. Ironically that was the intent, but I
do not choose good examples.

I was just exploring the idea of having to display the full signature at
some point.

Em dom, 27 de dez de 2015 às 23:11, Michel Fortin <michel.fortin at michelf.ca>
escreveu:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151228/7bcc2c7e/attachment-0001.html>


More information about the swift-evolution mailing list