[swift-evolution] [Review] Replace `typealias` keyword with `associatedtype` for associated type declarations

Matt Whiteside mwhiteside.dev at gmail.com
Mon Jan 4 11:47:49 CST 2016


> On Jan 2, 2016, at 22:38, Douglas Gregor via swift-evolution <swift-evolution at swift.org> wrote:
> 	* What is your evaluation of the proposal?
 
Taking an example from the swift source to compare an alternative, `type`, we have

public protocol _CollectionWrapperType : _SequenceWrapperType {
    associatedtype Base : CollectionType
    associatedtype Index : ForwardIndexType = Self.Base.Index
}

vs

public protocol _CollectionWrapperType : _SequenceWrapperType {
    type Base : CollectionType
    type Index : ForwardIndexType = Self.Base.Index
}

I think the version with `associatedtype` is a bit verbose, but that doesn’t seem like a big problem.  It might read a little more clearly as well.  I wouldn’t be unhappy with either of these alternatives, but `associatedtype` seems like a good choice.

> 	* Is the problem being addressed significant enough to warrant a change to Swift?
Yes.  I think it `typealias` should be used only as the swift equivalent of a C typedef.

> 	* Does this proposal fit well with the feel and direction of Swift?
Yes, because we want to improve readability and understandability.

> 	* If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
I haven’t used another language with this feature.

> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
In depth study.

> 
> More information about the Swift evolution process is available at
> 
> 	https://github.com/apple/swift-evolution/blob/master/process.md <https://github.com/apple/swift-evolution/blob/master/process.md>
> 
> 	Cheers,
> 	Doug Gregor
> 	Review Manager
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160104/d5c049d4/attachment.html>


More information about the swift-evolution mailing list