<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 Apr 11, 2016, at 1:01 AM, Jacob Bandes-Storch 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=""><div dir="ltr" class="">Doug wrote this in the Completing Generics manifesto, under "Minor extensions":<div class=""><br class=""></div><div class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><i class="">*Arbitrary requirements in protocols<br class=""></i></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">&nbsp;</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Currently, a new protocol can inherit from other protocols, introduce new associated types, and add new conformance constraints to associated types (by redeclaring an associated type from an inherited protocol). However, one cannot express more general constraints. Building on the example from “Recursive protocol constraints”, we really want the element type of a Sequence’s SubSequence to be the same as the element type of the Sequence, e.g.,<br class=""></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">&nbsp;</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">&nbsp; &nbsp; protocol Sequence {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; associatedtype Iterator : IteratorProtocol<br class="">&nbsp; &nbsp; &nbsp; &nbsp; …<br class="">&nbsp; &nbsp; &nbsp; &nbsp; associatedtype SubSequence : Sequence where SubSequence.Iterator.Element == Iterator.Element<br class="">&nbsp; &nbsp; }<br class=""></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class="">+1.</div><div class=""><br class=""></div><div class="">To make it into Swift 3, would this feature require a proposal of its own? </div></div></div></div></blockquote><div><br class=""></div><div>Yes. Also, be wary that the syntax above potentially conflicts with the syntax discussed as "moving the where clauses”:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/13886/focus=14058" class="">http://thread.gmane.org/gmane.comp.lang.swift.evolution/13886/focus=14058</a></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="">How feasible would it be to implement on top of the current system?</div></div></div></div></blockquote><br class=""></div><div>Definitely! The archetype builder would need to learn to check these extra where clauses, and one would need to be sure that the constraint solver is picking them up as well.</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div><br class=""></div><br class=""></body></html>