<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Tue, Dec 29, 2015, at 02:11 PM, Joe Groff wrote:<br></div>
<blockquote type="cite"><div>&nbsp;</div>
<div><blockquote type="cite"><div>On Dec 29, 2015, at 1:24 PM, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div>&nbsp;</div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div>Hi Kevin,<br></div>
<div>&nbsp;</div>
<div>Thanks for taking time to look at the proposal.<br></div>
<div>&nbsp;</div>
<div>The technique you show here is not bad, but it has several deficiencies IMO which are addressed by the solution in the proposal.<br></div>
<div>&nbsp;</div>
<div>1. Forwarding should be an implementation detail, not exposed as it is with this method.<br></div>
</div>
</div>
</blockquote><div>&nbsp;</div>
<div>This could theoretically be managed by access control on protocol conformances:<br></div>
<div>&nbsp;</div>
</div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;"><div><div>public struct Foo: internal SequenceTypeForwarder, public SequenceType { ... }<br></div>
</div>
</blockquote><div><div>&nbsp;</div>
<div>though that's even more boilerplatey, and makes it easy to accidentally expose more API than you intended to.<br></div>
</div>
</blockquote><div>&nbsp;</div>
<div>That's an interesting approach.<br></div>
<div>&nbsp;</div>
<div>Another workaround for this today is to use an operator (similar to how the stdlib uses ~&gt; internally for a lot of stuff) coupled with a phantom type. As an example (using ~&gt; because why not):<br></div>
<div>&nbsp;</div>
<div><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);">// phantom type</p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2">struct</span> _SequenceTypeForwarder {}</p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br></p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2">protocol</span> SequenceTypeForwarder : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa">SequenceType</span> {</p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2">typealias</span> ForwardedSequenceType : SequenceType</p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br></p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2">func</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> ~&gt;(this: </span>Self<span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2">_</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">: </span>_SequenceTypeForwarder<span style="font-variant-ligatures: no-common-ligatures; color: #000000">) -&gt; </span>ForwardedSequenceType</p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</p></div>
<div>&nbsp;</div>
<div>The need for the phantom type is a bit unfortunate (you can't just use SequenceTypeForwarder.Protocol because it complains about the Self or associated type requirements issue).<br></div>
<div>&nbsp;</div>
<div>-Kevin Ballard</div>
</body>
</html>