<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="">Do you mean allowing a type to conform to a protocol multiple times with a different set of types each time? That's an interesting idea; the generics manifesto describes the same feature but implemented using generics:&nbsp;<a href="https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md" class="">https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md</a>&nbsp;("Generic Protocols").<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 25, 2016, at 8:43 PM, T.J. Usiyan 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="">+1 for the proposal.<div class=""><br class=""></div><div class="">Another quirk of associated types is that they cannot be overloaded as far as I can tell. Requiring explicit declaration could move us toward allowing multiple types to serve. Does anyone else see this as a useful feature to pursue?</div><div class="">TJ</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, May 25, 2016 at 6:33 PM, Sean Heber via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class="">This is how I feel as well - I don't understand why we'd want to make the programmer do more work. Shouldn't the goal for the compiler and language be to make the end user programmer do *less* work while still getting solid results? I would like to see more and smarter magic like inference/context awareness in the language - not less!</div><div class=""><br class=""></div><div class="">l8r</div><div class="">Sean<br class=""><br class="">Sent from my iPad</div><div class=""><div class="h5"><div class=""><br class="">On May 25, 2016, at 5:37 PM, Leonardo Pessoa via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><div style="font-family:Calibri,sans-serif;font-size:11pt" class="">-1. I don't really see how this is a bad thing and why it has to change. To me this is one of the best features of the language and I want more of it (I've been through some situations it was totally obvious the expected type of a variable and the compiler couldn't infer it) not less.<br class=""><br class=""></div></div><div dir="ltr" class=""><hr class=""><span style="font-family:Calibri,sans-serif;font-size:11pt;font-weight:bold" class="">From: </span><span style="font-family:Calibri,sans-serif;font-size:11pt" class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">Matthew Johnson via swift-evolution</a></span><br class=""><span style="font-family:Calibri,sans-serif;font-size:11pt;font-weight:bold" class="">Sent: </span><span style="font-family:Calibri,sans-serif;font-size:11pt" class="">‎25/‎05/‎2016 07:06 PM</span><br class=""><span style="font-family:Calibri,sans-serif;font-size:11pt;font-weight:bold" class="">To: </span><span style="font-family:Calibri,sans-serif;font-size:11pt" class=""><a href="mailto:david@hartbit.com" target="_blank" class="">David Hart</a></span><br class=""><span style="font-family:Calibri,sans-serif;font-size:11pt;font-weight:bold" class="">Cc: </span><span style="font-family:Calibri,sans-serif;font-size:11pt" class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">Swift-evolution</a></span><br class=""><span style="font-family:Calibri,sans-serif;font-size:11pt;font-weight:bold" class="">Subject: </span><span style="font-family:Calibri,sans-serif;font-size:11pt" class="">Re: [swift-evolution] [Pitch] Remove associated type inference</span><br class=""><br class=""></div><div class="">I agree that if we’re going to do it we should probably do it in Swift 3.&nbsp; But it is a very convenient and useful feature that significantly lowers the bar of conforming to protocols with associated types (in many cases you can just implement the required members without thinking about the associated types).&nbsp; I think we should have a more detailed and compelling story about why we’re considering this change than I see in this proposal.</div><div class=""><br class=""></div>Are there any benefits users might receive from this change (assuming type checker architecture and bugs could eventually be ironed out)?&nbsp; Is it actively blocking desirable new features?&nbsp; If so what are they and in what way are they blocked?<div class=""><br class=""></div><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 25, 2016, at 4:43 PM, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div class="">Here’s a pitch for removing associated type inference as per the Generics Manifesto. If we want to do it, we’d better do it before Swift 3:<div class=""><br class=""></div><div class=""><h1 style="color:rgb(51,51,51);line-height:1.2;padding-bottom:0.3em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:2.25em;margin-top:0px!important;margin-right:0px;margin-bottom:16px;margin-left:0px;border-bottom-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;background-color:rgb(255,255,255)" class="">Remove associated type inference</h1><ul style="color:rgb(51,51,51);padding-left:2em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class=""><li class="">Proposal:&nbsp;<a style="color:rgb(64,120,192);text-decoration:none;background-color:transparent" href="https://github.com/apple/swift-evolution/blob/master/proposals/XXXX-remove-associated-type-inference.md" target="_blank" class="">SE-XXXX</a></li><li class="">Author:&nbsp;<a style="color:rgb(64,120,192);text-decoration:none;background-color:transparent" href="https://github.com/hartbit" target="_blank" class="">David Hart</a>,&nbsp;<a style="color:rgb(64,120,192);text-decoration:none;background-color:transparent" href="https://github.com/DougGregor" target="_blank" class="">Douglas Gregor</a></li><li class="">Status: TBD</li><li class="">Review manager: TBD</li></ul><h2 style="color:rgb(51,51,51);line-height:1.225;padding-bottom:0.3em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:1.75em;margin-top:1em;margin-bottom:16px;border-bottom-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;background-color:rgb(255,255,255)" class=""><a style="color:rgb(64,120,192);line-height:1;padding-right:2px;text-decoration:none;display:inline-block;background-color:transparent" href="https://github.com/hartbit/swift-evolution/blob/remove-associated-type-inference/proposals/XXXX-remove-associated-type-inference.md#introduction" target="_blank" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Introduction</h2><p style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class="">This proposal seeks to remove the inference of associated types in types conforming to protocols.</p><h2 style="color:rgb(51,51,51);line-height:1.225;padding-bottom:0.3em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:1.75em;margin-top:1em;margin-bottom:16px;border-bottom-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;background-color:rgb(255,255,255)" class=""><a style="color:rgb(64,120,192);line-height:1;padding-right:2px;text-decoration:none;display:inline-block;background-color:transparent" href="https://github.com/hartbit/swift-evolution/blob/remove-associated-type-inference/proposals/XXXX-remove-associated-type-inference.md#motivation" target="_blank" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Motivation</h2><p style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class="">Even if associated types inference in a useful feature, it is also a big source of bugs in the compiler. This proposal argues that the usefulness does not outweight its architectural complexity. As per the&nbsp;<a style="color:rgb(64,120,192);text-decoration:none;background-color:transparent" href="https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md" target="_blank" class="">Generics Manifesto</a>:</p><blockquote style="margin:0px 0px 16px;padding:0px 15px;color:rgb(119,119,119);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;border-left-color:rgb(221,221,221);border-left-width:4px;border-left-style:solid;background-color:rgb(255,255,255)" class=""><div style="margin-top:0px;margin-bottom:0px" class="">associated type inference is the only place in Swift where we have a global type inference problem: it has historically been a major source of bugs, and implementing it fully and correctly requires a drastically different architecture to the type checker.</div></blockquote><p style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class="">Because this is a breaking change, it would be beneficial to implement it for Swift 3.&nbsp;</p><h2 style="color:rgb(51,51,51);line-height:1.225;padding-bottom:0.3em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:1.75em;margin-top:1em;margin-bottom:16px;border-bottom-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;background-color:rgb(255,255,255)" class=""><a style="color:rgb(64,120,192);line-height:1;padding-right:2px;text-decoration:none;display:inline-block;background-color:transparent" href="https://github.com/hartbit/swift-evolution/blob/remove-associated-type-inference/proposals/XXXX-remove-associated-type-inference.md#detailed-design" target="_blank" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Detailed Design</h2><p style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class="">The proposal would remove associated type inference and make code which relied on it invalid:</p><div style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-bottom:16px;background-color:rgb(255,255,255)" class=""><pre style="padding:16px;border-radius:3px;line-height:1.45;overflow:auto;font-family:Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;background-color:rgb(247,247,247)" class=""><span style="color:rgb(167,29,93)" class="">protocol</span> IteratorProtocol {
  associatedtype Element
  <span style="color:rgb(167,29,93)" class="">mutating</span> <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">next</span>() <span style="color:rgb(167,29,93)" class="">-&gt;</span> Element?
}

<span style="color:rgb(167,29,93)" class="">struct</span> IntIterator <span style="color:rgb(167,29,93)" class="">:</span> IteratorProtocol {
  <span style="color:rgb(167,29,93)" class="">mutating</span> <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">next</span>() <span style="color:rgb(167,29,93)" class="">-&gt;</span> <span style="color:rgb(0,134,179)" class="">Int</span>? { <span style="color:rgb(167,29,93)" class="">...</span> }  <span style="color:rgb(150,152,150)" class="">// used to infer Element = Int</span>
}</pre></div><p style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class="">The compiler would generate an error message stating:&nbsp;<code style="margin:0px;padding:0.2em 0px;border-radius:3px;font-family:Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:14px;background-color:rgba(0,0,0,0.039215)" class="">error: IntIterator is missing its Element associated type declaration</code>. The code would have to be modified as follows to fix the error:</p><div style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-bottom:16px;background-color:rgb(255,255,255)" class=""><pre style="padding:16px;border-radius:3px;line-height:1.45;overflow:auto;font-family:Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;background-color:rgb(247,247,247)" class=""><span style="color:rgb(167,29,93)" class="">struct</span> IntIterator <span style="color:rgb(167,29,93)" class="">:</span> IteratorProtocol {
    <span style="color:rgb(167,29,93)" class="">typealias</span> Element <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">Int</span>
    <span style="color:rgb(167,29,93)" class="">mutating</span> <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">next</span>() <span style="color:rgb(167,29,93)" class="">-&gt;</span> <span style="color:rgb(0,134,179)" class="">Int</span>? { <span style="color:rgb(167,29,93)" class="">return</span> <span style="color:rgb(0,134,179)" class="">nil</span> }  <span style="color:rgb(150,152,150)" class="">// used to infer Element = Int</span>
}</pre></div><h2 style="color:rgb(51,51,51);line-height:1.225;padding-bottom:0.3em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:1.75em;margin-top:1em;margin-bottom:16px;border-bottom-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;background-color:rgb(255,255,255)" class=""><a style="color:rgb(64,120,192);line-height:1;padding-right:2px;text-decoration:none;display:inline-block;background-color:transparent" href="https://github.com/hartbit/swift-evolution/blob/remove-associated-type-inference/proposals/XXXX-remove-associated-type-inference.md#impact-on-existing-code" target="_blank" class=""><u class=""></u><u class=""></u><u class=""></u><u class=""></u></a>Impact on Existing Code</h2><p style="color:rgb(51,51,51);font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;margin-top:0px;margin-bottom:16px;background-color:rgb(255,255,255)" class="">This is a breaking change that will require conforming types which relied on the inference, including in the Standard Library, to explicitly declare associated types. A Fix-It could be introduced to add the&nbsp;<code style="margin:0px;padding:0.2em 0px;border-radius:3px;font-family:Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:14px;background-color:rgba(0,0,0,0.039215)" class="">typealias</code>&nbsp;and leave the type to be filled in. That way, all the type inference could be removed from the compiler.</p><h2 style="color:rgb(51,51,51);line-height:1.225;padding-bottom:0.3em;font-family:&quot;Helvetica Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:1.75em;margin-top:1em;margin-bottom:16px;border-bottom-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;background-color:rgb(255,255,255)" class=""><a style="color:rgb(64,120,192);line-height:1;padding-right:2px;text-decoration:none;display:inline-block;background-color:transparent" href="https://github.com/hartbit/swift-evolution/blob/remove-associated-type-inference/proposals/XXXX-remove-associated-type-inference.md#alternatives-considered" target="_blank" class=""><u class=""></u><u class=""></u></a></h2></div></div></div></blockquote></div></div></div><br class=""><div class="">[The entire original message is not included.]</div></div></blockquote></div></div><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><span class=""><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></span></div></blockquote></div><br class="">_______________________________________________<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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br 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></body></html>