[swift-evolution] [swift-evolution-announce] [Review] SE-0048: Generic Type Aliases

Dave Abrahams dabrahams at apple.com
Tue Mar 29 12:14:42 CDT 2016


on Mon Mar 28 2016, Chris Lattner <clattner-AT-apple.com> wrote:

> On Mar 24, 2016, at 1:18 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> Is the problem being addressed significant enough to warrant a change
>>> to Swift?
>> 
>> That's my biggest question about this proposal.  Yes, as the proposal
>> says, generic type aliases fill an obvious functional gap.  But what
>> real-world problems are they solving
>
> They allow you to make aliases for generic types, e.g. from the document:
>
> 	typealias StringDictionary<T> = Dictionary<String, T>
> 	typealias DictionaryOfStrings<T : Hashable> = Dictionary<T, String>
> 	typealias IntFunction<T> = (T) -> Int
> 	typealias Vec3<T> = (T, T, T)
> 	typealias BackwardTriple<T1,T2,T3> = (T3, T2, T1)

I know what the feature allows.  What I don't see is any burning need
for it.

> It is an inconsistency in the language that you can create aliases for
> non-generic types, but that you can’t make them for generic ones.
> Perhaps you are objecting to typealias as a feature at all?

I'm not objecting at all.  It's an obvious thing for us to do, and we
should do it at some point.  It just doesn't seem very impactful or
crucial.

>> and why should adding them be a priority?
>
> It is part of the general goal of completing the generics system, a
> stated Swift 3 goal.

True.  I just wonder if we should be frying bigger fish.

-- 
Dave


More information about the swift-evolution mailing list