<!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> </div>
<div><blockquote type="cite"><div>On Dec 29, 2015, at 1:24 PM, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
<div> </div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div>Hi Kevin,<br></div>
<div> </div>
<div>Thanks for taking time to look at the proposal.<br></div>
<div> </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> </div>
<div>1. Forwarding should be an implementation detail, not exposed as it is with this method.<br></div>
</div>
</div>
</blockquote><div> </div>
<div>This could theoretically be managed by access control on protocol conformances:<br></div>
<div> </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> </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> </div>
<div>That's an interesting approach.<br></div>
<div> </div>
<div>Another workaround for this today is to use an operator (similar to how the stdlib uses ~> internally for a lot of stuff) coupled with a phantom type. As an example (using ~> because why not):<br></div>
<div> </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;"> <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"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2">func</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> ~>(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">) -> </span>ForwardedSequenceType</p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</p></div>
<div> </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> </div>
<div>-Kevin Ballard</div>
</body>
</html>