<div dir="ltr">On Sun, Jan 8, 2017 at 4:09 AM, Adrian Zubarev <span dir="ltr">&lt;<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><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"><div style="word-wrap:break-word"><div class="gmail-m_-2655124390710574463bloop_markdown"><p>There are a few good points made here. It’s an interesting workaround to use <code>type(of:)</code> to get a similar behavior I wanted. My point is, that <code>Current</code> or call it static <code>Self</code> should exist to fill some gaps in our design patterns. Using <code>Self</code> in protocols should not always mean that you shall use the dynamic behavior. Yes on value types the dynamic type is the same conforming type.</p></div></div></blockquote><div><br></div><div>I&#39;m not sure in what way you intend to distinguish between static and dynamic Self in protocols.</div><div><br></div><div>- If class `Base` conforms to protocol `P`, then final class `Derived : Base` also conforms to protocol `P`. This is, AFAIK, non-negotiable.</div><div><br></div><div>- In Swift, a type can only conform to a protocol in one way. This is unlikely to change in Swift 4 or 5.</div><div><br></div><div>- If `P` guarantees a method called `frobnicate()` and we have `let foo = Derived()`, then `foo.frobnicate()` and `(foo as Base).frobnicate()` invoke the same method. See: &lt;<a href="https://www.raizlabs.com/dev/2016/12/swift-method-dispatch/">https://www.raizlabs.com/dev/2016/12/swift-method-dispatch/</a>&gt; about dispatch rules.</div><div><br></div><div>- If `frobnicate()` is guaranteed by `P` to return a value of type `Self`, `Base.frobnicate()` must provide an implementation that returns a value of type `Self` and `Derived.frobnicate()` must provide an implementation that returns a value of type `Derived`. Both `foo.frobnicate()` and `(foo as Base).frobnicate()` invoke the implementation on `Derived`, which returns a value of type `Derived`.</div><div><br></div><div>- As Anton wrote, one improvement is to make it possible to write `Base.frobnicate()` by spelling out the return value as `Base` instead of `Self`, with the consequence that `Derived` _must_ also provide its own implementation that spells out `Derived`. However, unless I&#39;m mistaken, since Swift allows overloading by return type, `Derived.frobnicate()` would be an overload and not an override of `Base.frobnicate()`, and yet `(foo as Base).frobnicate()` must dispatch to the implementation on `Derived`.</div><div><br></div><div>- If `frobnicate()` could be guaranteed to return a value of type `StaticSelf`, `Base.frobnicate()` must provide an implementation that returns a value of type `Base` and `Derived.frobnicate()` must still provide an implementation that returns a value of type `Derived`. Both `foo.frobnicate()` and `(foo as Base).frobnicate()` must still invoke the implementation on `Derived`, which still returns a value of type `Derived`.</div><div><br></div><div>- If Anton&#39;s suggestion is adopted and the issues with dispatch overcome, then the above would be possible, but both the `StaticSelf` and `Self` versions appear to do the same thing. If Anton&#39;s suggestion is not adopted, then the above would not be possible.</div><div><br></div><div>So, why do you think you need `StaticSelf` in the context of protocols?</div><div><br></div><div><br></div><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"><div style="word-wrap:break-word"><div class="gmail-m_-2655124390710574463bloop_markdown"><p> </p>

<pre><code class="gmail-m_-2655124390710574463swift">// All these protocol do not compile
// This is not real world example, but IMO should be possible
protocol P : class {
     
    associatedtype StaticSelf : AnyObject
    func castOrTrap&lt;T : StaticSelf&gt;() -&gt; T
}

protocol P : class {
     
    associatedtype StaticSelf : Self
    func castOrTrap&lt;T : StaticSelf&gt;() -&gt; T
}

protocol P : class {
     
    func castOrTrap&lt;T : Self&gt;() -&gt; T
}
</code></pre>

<p>The absence of static <code>Self</code> does hurt the flexibility of the language to design a specific but yet clear behavior. The <code>P</code> protocol is meant to have a static <code>Self</code>, where conforming to it would result in a shorthand version using <code>StaticSelf/Current</code> or the conforming type:</p>

<pre><code class="gmail-m_-2655124390710574463swift">class A : P {
     
    func castOrTrap&lt;T : Current&gt;() -&gt; T { … }
    // or
    func castOrTrap&lt;T : A&gt;() -&gt; T { … }
}
</code></pre>

<p>I cannot think of a possible workaround here except of defining that method on the base type itself. If other not derived classes need to have this pattern, I cannot create an ancestor protocol as I might would like.</p>

<hr>

<p>The forced <code>required init</code> might be a good workaround for the issue from some previous post, but is it really what we always wanted? This restriction lives only on the non-final classes because <code>Self</code> there is dynamic, which feels kinda inconsistent. As I already mentioned, I’d be happy if we could drop the restriction on the conforming type to allow the user to decide if we want to follow the contract of using <code>self</code> (lowercased) and <code>type(of: self)</code> or could simply override <code>Self</code> with <code>ContainingTypeName</code>. That would solve that issue, if I’m not totally missing here something.</p>

<p>But the issue from above remans unsolved. Furthermore, does dynamic <code>Self</code> make any sense on non-final classes as a parameter type? Can anyone show me a plausible code snippet for that?</p>

<hr>

<p>Sure my arguments are more like <strong>might</strong>, <strong>want</strong> etc. and not that much of a weight, but that’s my honest opinion that some restrictions makes the language less flexible as it could be.</p>

<p><code>Self</code> is exactly like <code>.Type</code> which might also be magically <code>.Protocol</code>. The static and dynamic behaviors are baked into one place. :/</p>

<p></p></div><div class="gmail-m_-2655124390710574463bloop_original_html"><span class="gmail-"><div id="gmail-m_-2655124390710574463bloop_customfont" style="font-family:helvetica,arial;font-size:13px;color:rgb(0,0,0);margin:0px"><br></div> <br> <div id="gmail-m_-2655124390710574463bloop_sign_1483868455556030976" class="gmail-m_-2655124390710574463bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <br></span><div><div class="gmail-h5"><p class="gmail-m_-2655124390710574463airmail_on">Am 8. Januar 2017 um 00:51:32, Xiaodi Wu via swift-evolution (<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>) schrieb:</p> </div></div><blockquote type="cite" class="gmail-m_-2655124390710574463clean_bq"><span><div><div></div><div><div><div class="gmail-h5">





<div dir="ltr">On Sat, Jan 7, 2017 at 5:33 PM, Braeden Profile
<span dir="ltr">&lt;<a href="mailto:jhaezhyr12@gmail.com" target="_blank">jhaezhyr12@gmail.com</a>&gt;</span> wrote:<br>
<div class="gmail_extra">
<div class="gmail_quote">
<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">
<div style="word-wrap:break-word">
<div>
<div class="gmail-m_-2655124390710574463h5">
<div>
<blockquote type="cite">
<div>
<div dir="ltr" style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(79,129,135)">
<div style="font-family:helvetica;font-size:12px"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(146,146,146)">
<br></span></div>
<div style="font-family:helvetica;font-size:12px"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(146,146,146)">
Of course, I would love being able to use an initializer setup, but
there are serious bugs in the implementation.</span></div>
<div style="font-family:helvetica;font-size:12px"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(146,146,146)">
<br></span></div>
<div style="font-family:helvetica;font-size:12px">
<pre style="font-family:consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:0.94em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);white-space:pre-wrap;word-wrap:break-word;padding:5px"></pre>
<div style="white-space:normal;font-family:helvetica;font-size:12px">
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,1)">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(146,146,146)">
<span style="font-variant-ligatures:no-common-ligatures">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Clonable</span></span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">init</span><span style="font-variant-ligatures:no-common-ligatures">(other: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(73,134,114)">Self</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,1)">
<span style="font-variant-ligatures:no-common-ligatures">extension</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(95,174,174)">Clonable</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">func</span><span style="font-variant-ligatures:no-common-ligatures"> clone()
-&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(73,134,114)">Self</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{ </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">return</span><span style="font-variant-ligatures:no-common-ligatures"> type(of: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">self</span><span style="font-variant-ligatures:no-common-ligatures">).</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">init</span><span style="font-variant-ligatures:no-common-ligatures">(o<wbr>ther: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">self</span><span style="font-variant-ligatures:no-common-ligatures">)
}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(95,174,174)">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">class</span><span style="font-variant-ligatures:no-common-ligatures"> Base: </span><span style="font-variant-ligatures:no-common-ligatures">Clonable</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">var</span><span style="font-variant-ligatures:no-common-ligatures"> x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(91,38,153)">Int</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br class="gmail-m_-2655124390710574463m_-311399833560624468m_-602078394375739685webkit-block-placeholder">
</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">init</span><span style="font-variant-ligatures:no-common-ligatures">(x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(91,38,153)">Int</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{ </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">self</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">x</span><span style="font-variant-ligatures:no-common-ligatures"> =
x }</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br class="gmail-m_-2655124390710574463m_-311399833560624468m_-602078394375739685webkit-block-placeholder">
</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,1)">
<span style="font-variant-ligatures:no-common-ligatures">required</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures">init</span><span style="font-variant-ligatures:no-common-ligatures">(other: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(95,174,174)">Base</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{ </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">self</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">x</span><span style="font-variant-ligatures:no-common-ligatures"> =
other.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">x</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">class</span><span style="font-variant-ligatures:no-common-ligatures"> Derived: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(95,174,174)">Base</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(91,38,153)">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">var</span><span style="font-variant-ligatures:no-common-ligatures"> y: </span><span style="font-variant-ligatures:no-common-ligatures">String</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br class="gmail-m_-2655124390710574463m_-311399833560624468m_-602078394375739685webkit-block-placeholder">
</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">init</span><span style="font-variant-ligatures:no-common-ligatures">(x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(91,38,153)">Int</span><span style="font-variant-ligatures:no-common-ligatures">,
y: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(91,38,153)">String</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">self</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">y</span><span style="font-variant-ligatures:no-common-ligatures"> =
y</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">super</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">init</span><span style="font-variant-ligatures:no-common-ligatures">(x:
x)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br class="gmail-m_-2655124390710574463m_-311399833560624468m_-602078394375739685webkit-block-placeholder">
</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(146,146,146)">
<span style="font-variant-ligatures:no-common-ligatures">// Should
be required by the Clonable protocol, but it isn&#39;t.</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,1)">
<span style="font-variant-ligatures:no-common-ligatures">required</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures">init</span><span style="font-variant-ligatures:no-common-ligatures">(other: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(95,174,174)">Derived</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">{</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">self</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">y</span><span style="font-variant-ligatures:no-common-ligatures"> =
other.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">y</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">super</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">init</span><span style="font-variant-ligatures:no-common-ligatures">(other:
other)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br class="gmail-m_-2655124390710574463m_-311399833560624468m_-602078394375739685webkit-block-placeholder">
</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(146,146,146)">
<span style="font-variant-ligatures:no-common-ligatures">//
Required because it was `required` in Base.  Even a
`Derived` calls this initializer to clone, which is
wrong.  Bugs abound.</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,143,1)">
<span style="font-variant-ligatures:no-common-ligatures">required</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures">init</span><span style="font-variant-ligatures:no-common-ligatures">(other: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(95,174,174)">Base</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(2,37,188)">
<span style="font-variant-ligatures:no-common-ligatures">{ </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(61,29,129)">fatalError</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures">&quot;init(other:)
is wrong.&quot;</span><span style="font-variant-ligatures:no-common-ligatures">) }</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px">
<br></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">let</span><span style="font-variant-ligatures:no-common-ligatures"> me
= </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(95,174,174)">Derived</span><span style="font-variant-ligatures:no-common-ligatures">(x: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">1</span><span style="font-variant-ligatures:no-common-ligatures">,
y: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(2,37,188)">&quot;food&quot;</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(146,146,146)">
<span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">let</span><span style="font-variant-ligatures:no-common-ligatures"> alienClone
= </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">me</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)">clone</span><span style="font-variant-ligatures:no-common-ligatures">() </span><span style="font-variant-ligatures:no-common-ligatures">//
&quot;init(other:) is wrong.&quot;</span></div>
<div><br></div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br></div>
<div>Agree. That seems wrong. Great example.</div>
</div>
</div>
</div>
</div>
</blockquote>
<br></div>
</div>
</div>
<div>So, is this odd behavior intentional, a bug, or a design
deficiency?  I would think that when a protocol has a method
or initializer has `Self` parameters—like in Clonable—every
subclass would be required to implement its own specialized version
(much like a required initializer).  That would be a special
case of the protocol system, though.</div>
<div><br></div>
<div>As it sits, even fixing the calling behavior of my example
leaves us with the problem of subclasses inheriting inapplicable
required initializers from superclasses that actually don’t make
any sense.</div>
<div><br></div>
<div>Does this deserve its own thread?</div>
</div>
</blockquote>
<div><br></div>
<div>Dunno, maybe best to have its own thread. It&#39;s not mentioned
as part of SE-0068, but IMO a complete design that respects the
spirit of that proposal *should* involve allowing you to
write:</div>
<div><br></div>
<div>```</div>
<div>class Base : Clonable {</div>
<div>  required init(other: Self) { ... }</div>
<div>}</div>
<div><br></div>
<div>class Derived : Base {</div>
<div>  required init(other: Self) { ... }</div>
<div>}</div>
<div>```</div>
<div><br></div>
</div>
<br></div>
</div></div></div><span class="gmail-">


______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></span></div></div></span></blockquote></div><div class="gmail-m_-2655124390710574463bloop_markdown"><p></p></div></div></blockquote></div><br></div></div>