<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 29, 2017, at 1:03 PM, Matt Whiteside via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">In Swift 3.1, I was happy to see that we can now extend types with concrete constraints. &nbsp;I think one other feature which fits nicely with this new capability would be extending typealiases, like this:</div><div class=""><br class=""></div><div class=""><b class=""><font face="FiraMono-Regular" class="">typealias Vector = Array&lt;Float&gt;</font></b></div><div class=""><b class=""><font face="FiraMono-Regular" class=""><br class=""></font></b></div><div class=""><b class=""><font face="FiraMono-Regular" class="">extension Vector {</font></b><b class=""><font face="FiraMono-Regular" class="">&nbsp;</font></b></div><div class=""><b class=""><font face="FiraMono-Regular" class="">&nbsp; &nbsp;...</font></b></div><div class=""><b class=""><font face="FiraMono-Regular" class="">}</font></b></div><div class=""><b class=""><br class=""></b></div><div class="">Which currently doesn't compile due to: &nbsp;"Constrained extension must be declared on the unspecialized generic type 'Array' with constraints specified by a 'where’ clause”</div><div class=""><br class=""></div><div class="">What is other people’s interest level? &nbsp;How possible would it be to add this?</div></div></div></blockquote><div><br class=""></div>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:</div><div><br class=""></div><div>typealias OptionalArray&lt;T&gt; = Optional&lt;Array&lt;T&gt;&gt;</div><div><br class=""></div><div>extension OptionalArray {</div><div>&nbsp; …</div><div>}</div><div><br class=""></div><div>Without generic typealiases, you might imagine this could be written as something like</div><div><br class=""></div><div>extension &lt;T&gt; Optional&lt;Array&lt;T&gt;&gt; {</div><div>&nbsp; …</div><div>}</div><div><br class=""></div><div>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.</div><div><br class=""></div><div>Slava</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">-Matt</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>