<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=""><div class="">This request isn’t really about typealias at all. &nbsp;It has two elements.</div><div class=""><br class=""></div><div class="">First, it’s about the ability to bind Self and / or associated types in a protocol and use the result as a type. &nbsp;This is highly desirable and is similar to features in the ML module system.</div><div class=""><br class=""></div><div class="">First is the ability to use a protocol with self or associated types as a type, not just a generic constraint:</div><div class=""><br class=""></div><div class="">protocol&lt;CollectionType&nbsp;where CollectionType.Generator.Element == CGPoint&gt;</div><div class=""><br class=""></div><div class="">I don’t think the `T:` label is necessary here as the protocol name serves as a good identifier in this context. &nbsp;Although the protocol name could probably be omitted when there is only one protocol here as it is implicit:</div><div class=""><br class=""></div><div class="">protocol&lt;CollectionType&nbsp;where Generator.Element == CGPoint&gt;</div><div class=""><br class=""></div><div class="">The general form of this would look like:</div><div class=""><br class=""></div><div class="">protocol&lt;P1, P2, P3 where *list of constraints*&gt;</div><div class=""><br class=""></div><div class="">In this case the protocol name would be required, at least when more than one protocol in the list have an associated type with the same name (and possibly in all cases). &nbsp;The list of constraints could identify associated types, bind them to concrete types, constrain Self to a specific superclass, etc. &nbsp;The Self constraint might look like this:</div><div class=""><br class=""></div><div class="">protocol&lt;P1, P2, P3 where Self: UIViewController&gt;</div><div class=""><br class=""></div><div class="">Ideally we would not need to bind all associated types in the protocol in order to use it at a type, but would only be allowed to use members that do not mention the unbound associated type in their signature.</div><div class=""><br class=""></div><div class="">Once we have the ability to bind associated types and use the result as a type, the typealias use falls out automatically.<br class=""><div class=""><br class=""></div><div class="">Second, it’s about the ability to extend a typealias where some generic constraints are specified in the typealias. &nbsp;This would allow us to re-use the binding of generic constraints, but could be confusing if the extension is far removed in source from the typealias. &nbsp;I’m not sure how I feel about this part of the proposal.</div><div class=""><br class=""></div><div class="">Matthew</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 4:28 AM, Adrian Kashivskyy 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="">I believe this could be achieved using generic typealiases, proposed here:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/2015-December/000132.html" class="">https://lists.swift.org/pipermail/swift-evolution/2015-December/000132.html</a><br class=""><div class="">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font color="#929292" class=""><br class="Apple-interchange-newline">Pozdrawiam – Regards,</font></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font color="#929292" class="">Adrian Kashivskyy</font></div>
</div>
<br class=""><div style="" class=""><blockquote type="cite" class=""><div class="">Wiadomość napisana przez QQ Mail via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; w dniu 06.12.2015, o godz. 08:17:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">If typealias support protocol constraint, I think we can reuse a lot of code, also more readable</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">For Example:&nbsp;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">typealias</span> PointCollection = <span style="color: rgb(187, 44, 162);" class="">protocol</span>&lt;<span style="color: rgb(112, 61, 170);" class="">T</span>:CollectionType <span style="color: rgb(187, 44, 162);" class="">where</span> T.Generator.Element == CGPoint&gt;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">public<span style="" class=""> </span>extension<span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">PointCollection</span><span style="" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Q0Y0L54uOhrrHtFzGFlMmzHCkni7p1uaN05dut7Y5S43DlrrTk95XmAmHVPYovVD-2FtynIwxv7tCwyJp7iPY3rUcSF3DrOQMj6nHlg9dWwb4BG7rVw-2FY0fgdcD7LPRH3nZjbozTzyB3LZPmsMoJem2Spo16F0NRxWQPIrOIFeRilEluDsxprNQsO6zI25lADMlpVz9fRwkGa78fC1QE66T1LvlVu4P-2FOH3HGkJDsJYXI-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAeYK2gLUFh22QZmAFYWEnllZbrLCduQDfuczoGFgOewO-2FRt8AkeEWmA6VPtUsBA7AE1yBCbCo8EXTS9AYg0nsn7rwzeWL-2FQeYKlAMOG2tolLmgeHEzwYFbTbfDs6juAojYGMWybrqRawZe03tVW5ffJsJpqu1Q3e0TFStbjPMw51GPDvIuIy8g-2BBoBk2MM8CyY-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</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=""></div></div></body></html>