[swift-evolution] [pitch] Comparison Reform
Xiaodi Wu
xiaodi.wu at gmail.com
Thu Apr 13 20:49:25 CDT 2017
Right; clearly, the difference between the proposed @_implements design and
yours will be subtle (but, when it strikes, a totally different function is
invoked) and it will be difficult for even advanced Swift users to
understand.
On Thu, Apr 13, 2017 at 20:29 Jaden Geller <jaden.geller at gmail.com> wrote:
> Oh, I definitely overlooked that part. Thanks for that clarification! I
> had assumed the compiler changes were only necessary for allowing circular
> default implementations while still requiring at least one requirement be
> implemented.
>
> That said, it’s possible to implement something very, very similar without
> compiler changes:
>
> https://gist.github.com/JadenGeller/7566b3b64b5597ee57e8a509f6fc4bb3#file-context-swift-L43
>
> Cheers,
> Jaden Geller
>
> On Apr 13, 2017, at 5:58 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
> Jaden, the proposal literally says that a compiler feature named
> "@_implements" is necessary for the proposed design to work. You can see
> WIP for that feature in the apple/swift repo.
>
>
> On Thu, Apr 13, 2017 at 19:55 Jaden Geller <jaden.geller at gmail.com> wrote:
>
>>
>> On Apr 13, 2017, at 5:18 PM, Xiaodi Wu via swift-evolution <
>> swift-evolution at swift.org> wrote:
>>
>> Actually, the fact that this behavior cannot even be achieved without
>> currently non-existent compiler features means that it is not possible to
>> understand what's truly going on without reading *this document*, after
>> mastering *both* IEEE floating point *and* Swift
>> generics/protocols/extensions/static vs. dynamic dispatch. All to use `==`
>> correctly. Which is to say, most people will simply not even know if they
>> happen to be using the `==` they did not intend to use.
>>
>>
>> If I understand correctly, I think you’re mistaken. The compiler already
>> selects overloads based on generic context. If `T: FloatingPoint`, then
>> it’ll choose the `==` with signature `<T: FloatingPoint> (T, T) -> Bool`.
>> If `T: Equatable`, then it’ll choose the `==` with signature `<T:
>> Equatable> (T, T) -> Bool`. No new compiler features are necessary for this
>> specific behavior.
>>
>> Cheers,
>> Jaden Geller
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170414/51301200/attachment.html>
More information about the swift-evolution
mailing list