[swift-evolution] [swift-evolution-announce] [Review] SE-0048: Generic Type Aliases
Chris Lattner
clattner at apple.com
Mon Mar 28 23:28:21 CDT 2016
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)
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?
> 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.
-Chris
More information about the swift-evolution
mailing list