<div dir="ltr">In my current proposal, stored properties of protocols have no abilities beyond that of structs. They cannot be declared in extensions, that's intentional. Could you give an example where such decoupled definition would be better than multiple mixins, for example?</div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-27 19:17 GMT+03:00 Trent Nadeau <span dir="ltr"><<a href="mailto:tanadeau@gmail.com" target="_blank">tanadeau@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">One limitation for "mixin" protocols would be that they can't be retroactively modeled, e.g. by having an extension for that protocol on a type outside of its file of definition. Allowing this would make the size of structs and classes unknowable to the compiler as an extension in another library could change the size of all instances.<div><br></div><div>That limitation is restrictive enough that having a special type of protocol and an associated keyword ("mixin") would probably be beneficial. The compiler could then easily check the intent of the protocol and ensure that a library doesn't break existing extensions just by adding a stored property. Only mixin protocols would have this capability. </div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Sat, Feb 27, 2016 at 9:00 AM, Radosław Pietruszewski <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>This is compelling to me.</div><div><br></div><div>I haven’t put enough thought into it to make up my mind about it, but a mixin system would solve a problem I’m currently struggling with.</div><div><br></div><div>I’ve been working on cleaning up the codebase of my iOS/Mac app, and I’m trying to reduce duplication between the codebases. The problem is, there are things that aren’t easy to completely encapsulate into a separate, universal class — things that have bits and pieces in common, but different overall shape.</div><div><br></div><div>Perhaps I should encapsulate them anyway, add a level of indirection, inject dependencies… But a mixin is an abstraction that would allow me to extract common parts in an easier way.</div><br><div>
<div>— Radek</div>
</div>
<br><div><blockquote type="cite"><div><div><div>On 27 Feb 2016, at 10:59, Антон Жилин via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></div></div><div><div><div><div dir="ltr">Some people opposed to Abstract Classes proposal (including myself) have said that mixins could solve the problem better.<div>So I prepaired a proposal draft to add stored properties to protocols. Here it is:</div><div><a href="https://gist.github.com/Anton3/f0550922c1be0fc5447c" target="_blank">https://gist.github.com/Anton3/f0550922c1be0fc5447c</a><br></div><div><br></div><div>P.S. I added a `mixin` keyword in the beginning, but we can opt to just extend protocols, which I mention in "alternatives".</div></div></div></div><span>
_______________________________________________<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/mailman/listinfo/swift-evolution</a><br></span></div></blockquote></div><br></div><br>_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div>Trent Nadeau</div>
</font></span></div>
</blockquote></div><br></div>