<html><head></head><body style="word-wrap:break-word"><div></div><div>



<style>
<![CDATA[
body{font-family:Helvetica,Arial;font-size:13px}
]]>
</style>
<title></title>



<div id="bloop_customfont" style="margin:0px">Consider the following (you can paste it in a Playground to see the error):</div>
<div id="bloop_customfont" style="margin:0px"><br></div>
<div>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span>
<span style="font-variant-ligatures: no-common-ligatures">Node {
}</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span>
<span style="font-variant-ligatures: no-common-ligatures">Containable :</span>
<span style="color:#4f8187">Node</span><span style="font-variant-ligatures: no-common-ligatures">{}</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; : 14px;">
<br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">protocol</span>
<span style="font-variant-ligatures: no-common-ligatures">Refers
{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
 </span> <span style="color:#bb2ca2">var</span>
<span style="font-variant-ligatures: no-common-ligatures">to
:</span> <span style="color:#4f8187">Node</span>
<span style="font-variant-ligatures: no-common-ligatures">{</span><span style="color:#bb2ca2">get</span><span style="font-variant-ligatures: no-common-ligatures">}</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures">}</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; : 14px;">
<br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span>
<span style="font-variant-ligatures: no-common-ligatures">Link
:</span> <span style="color:#4f8187">Refers</span>
<span style="font-variant-ligatures: no-common-ligatures">{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
 </span> <span style="color:#bb2ca2">var</span>
<span style="font-variant-ligatures: no-common-ligatures">to
:</span> <span style="color:#4f8187">Node</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
 </span> <span style="color:#bb2ca2">init</span><span style="font-variant-ligatures: no-common-ligatures">(n
:</span> <span style="color:#4f8187">Node</span><span style="font-variant-ligatures: no-common-ligatures">)
{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
     </span> <span style="color:#4f8187">to</span>
<span style="font-variant-ligatures: no-common-ligatures">=
n</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
  }</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures">}</span></p>
<p style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; : 14px;">
<br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="color:#bb2ca2">class</span>
<span style="font-variant-ligatures: no-common-ligatures">Contains
:</span> <span style="color:#4f8187">Refers</span>
<span style="font-variant-ligatures: no-common-ligatures">{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">
<span style="color:#000000"> 
 </span> <span style="color:#bb2ca2">var</span>
<span style="color:#000000">to
:</span> <span style="font-variant-ligatures: no-common-ligatures">Containable</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
 </span> <span style="color:#bb2ca2">init</span><span style="font-variant-ligatures: no-common-ligatures">(c
:</span> <span style="color:#4f8187">Containable</span><span style="font-variant-ligatures: no-common-ligatures">)
{</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
     </span> <span style="color:#4f8187">to</span>
<span style="font-variant-ligatures: no-common-ligatures">=
c</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures"> 
  }</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">
<span style="font-variant-ligatures: no-common-ligatures">}</span></p>
</div>
<div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div>
This currently does not work because it seems that to adopt a protocol, the type of
protocol var must match exactly.</div><div><br><div>It would be great if objects could be said to adopt a protocol if the type of the var is the type or a derived type.  </div><div>This would allow me to treat the structure in a type safe way (i.e. only a Containable can have a Contains relationship), </div><div>while me to have a set of Refers and iterate through each Node.</div><div><br>
<div>Is there a reason why the type must match exactly?  Or
could protocols be enhanced to to allow matching</div>
<div>derived types, similar to assignment and func parameter rules?  </div><div><br></div><div><br></div><div><span style="font-family:helvetica,arial">Mark</span></div>
</div>


</div></body></html>