[swift-evolution] [Pitch] Remove type inference for associated types
Brandon Knope
bknope at me.com
Thu Jun 30 08:22:08 CDT 2016
But surely using two different keywords could seem confusing to many as part of the same system?
Using associatedtype in the declaration and then typealias in the conforming type just seems inconsistent and ripe for confusion. '
I am curious if any advanced Swift users still get tripped up here
Brandon
Sent from my iPad
On Jun 30, 2016, at 8:53 AM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> On Jun 29, 2016, at 6:55 AM, Brandon Knope via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> What's the rationale for having associatedtype in protocols and typealias in the conforming types?
>
> I didn't design it, but here's how I think about it: The associated type requirement merely states that there must be a type with this name meeting these criteria. `typealias` is one way to satisfy that requirement, but you can also just define a nested type with that name:
>
> struct MyCollection {
> struct Index: Comparable { … }
> }
>
> Should you replace `struct` with `associatedtype`? No? Then why would you replace `typealias` with `associatedtype`?
>
> --
> Brent Royal-Gordon
> Architechies
>
More information about the swift-evolution
mailing list