[swift-evolution] [swift-evolution-announce] [Review] SE-0089: Replace protocol<P1, P2> syntax with Any<P1, P2>

L Mihalkovic laurent.mihalkovic at gmail.com
Thu Jun 9 14:23:49 CDT 2016


> On Jun 9, 2016, at 7:50 PM, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> Am 09.06.2016 um 18:49 schrieb Dave Abrahams via swift-evolution <swift-evolution at swift.org>:
>> 
>> 
>> on Wed Jun 08 2016, Jordan Rose <swift-evolution at swift.org> wrote:
>> 
>>>> On Jun 8, 2016, at 13:16, Dave Abrahams via swift-evolution
>>>> <swift-evolution at swift.org> wrote:
>>>> 
>>>> 
>>>> on Wed Jun 08 2016, Thorsten Seitz
>>> 
>>>> <swift-evolution at swift.org
>>>> <mailto:swift-evolution at swift.org>>
>>>> wrote:
>>>> 
>>>>> Ah, thanks, I forgot!  I still consider this a bug, though (will have
>>>>> to read up again what the reasons are for that behavior).
>>>> 
>>>> Yes, but in the case of the issue we're discussing, the choices are:
>>>> 
>>>> 1. Omit from the existential's API any protocol requirements that depend
>>>> on Self or associated types, in which case it *can't* conform to
>>>> itself because it doesn't fulfill the requirements.
>>>> 
>>>> 2. Erase type relationships and trap at runtime when they don't line up.
>>>> 
>>>> Matthew has been arguing against #2, but you can't “fix the bug” without
>>>> it.
>>> 
>>> #1 has been my preference for a while as well, at least as a starting
>>> point. 
>> 
>> I should point out that with the resyntaxing of existentials to
>> Any<Protocols...>, the idea that Collection's existential doesn't
>> conform to Collection becomes far less absurd than it was, so maybe this
>> is not so bad.
> 
> I think the problem is more that Any<Collection> does not conform to a specific value for a type parameter T: Collection
> 
> What I mean by this is that `Collection` denotes a type family, a generic parameter `T: Collection` denotes a specific (though unknown) member of that type family and `Any<Collection>` denotes the type family again, so there is really no point in writing Any<Collection> IMO. 
> The type family cannot conform to T because T is just one fixed member of it.
> It conforms to itself, though, as I can write
> let c1: Any<Collection> = …
> let c2: Any<Collection> = c1
> 
> That’s why I think that we could just drop Any<Collection> and simply write Collection.

I was exploring this path a bit… 

https://gist.github.com/lmihalkovic/8aa66542f5cc4592e967bade260477ef



> -Thorsten
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list