[swift-evolution] extending typealiases
Slava Pestov
spestov at apple.com
Sun Jan 29 22:35:45 CST 2017
> On Jan 29, 2017, at 1:03 PM, Matt Whiteside via swift-evolution <swift-evolution at swift.org> wrote:
>
> In Swift 3.1, I was happy to see that we can now extend types with concrete constraints. I think one other feature which fits nicely with this new capability would be extending typealiases, like this:
>
> typealias Vector = Array<Float>
>
> extension Vector {
> ...
> }
>
> Which currently doesn't compile due to: "Constrained extension must be declared on the unspecialized generic type 'Array' with constraints specified by a 'where’ clause”
>
> What is other people’s interest level? How possible would it be to add this?
I think this particular case would be pretty easy to add, but there is a more general case with generic typealiases that requires some thought:
typealias OptionalArray<T> = Optional<Array<T>>
extension OptionalArray {
…
}
Without generic typealiases, you might imagine this could be written as something like
extension <T> Optional<Array<T>> {
…
}
I think this is called out in the generics manifesto as a potential future feature. I’m not sure how much work it would take to add it but I imagine it’s not entirely trivial.
Slava
>
> -Matt
>
>
>
> _______________________________________________
> 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/20170129/b23a273c/attachment.html>
More information about the swift-evolution
mailing list