<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="">Regarding multiple inheritance of protocols, it shouldn’t be a huge problem from the developer’s perspective to have multiple values for the same property because you’d have the same expectation as if there had just been multiple assignments: last one wins. The problem I’d see for the example scenario is that the semantics of the property may be completely different, in which case having a value that the protocol doesn’t expect may break it. The only adequate protections for that kind of matter is either preventing declarations of the same property across multiple included protocols or giving them their own namespaces (which would be a problem in itself).<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 27 Feb 2016, at 20:30, David Scrève 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>I have already considered adding store properties to protocols before proposing abstract classes, but there are some issues :&nbsp;<div class=""><br class=""></div><div class="">1 - If protocols can have stored properties and default method implementation, how do you explain to newby the difference between a class and a protocol ? There is the same problem with Java 8 and interface which make learning to student really painfull….</div><div class="">In short words, protocol will became a sort of class and no longer a true kind of contract to conform to.</div><div class=""><br class=""></div><div class="">2 - What about compatibility with Objective C ?</div><div class=""><br class=""></div><div class="">3- more interesting problem : At the moment, multiple inheritance for protocol is allowed. When introducing store property in protocol, you introduce a major issue that C++ have : the diamond problem.</div><div class=""><br class=""></div><div class="">Example :&nbsp;</div><div class=""><br class=""></div><div class="">protocol A {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var value = 34</div><div class="">}&nbsp;<br class=""><div class=""><br class="webkit-block-placeholder"></div><div class="">protocol B {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var value = 23</div><div class="">}</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> myClass : <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">A</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">B</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="" class="">&nbsp; &nbsp; </span>func<span style="" class=""> </span>init<span style="" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; print("Value&nbsp; : \(value));</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">What should be print out ? how do you manage access to A.value and B.value ?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div class="">
<div class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""></pre><blockquote type="cite" class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Some people opposed to Abstract Classes proposal (including myself) have
said that mixins could solve the problem better.
So I prepaired a proposal draft to add stored properties to protocols. Here
it is:
<a href="https://gist.github.com/Anton3/f0550922c1be0fc5447c" class="">https://gist.github.com/Anton3/f0550922c1be0fc5447c</a>

P.S. I added a `mixin` keyword in the beginning, but we can opt to just
extend protocols, which I mention in "alternatives".</pre></blockquote><div class=""><br class=""></div></div>
</div>
<br class=""></div></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>