<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=""><div apple-content-edited="true" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Hello TJ,</div><div apple-content-edited="true" class=""><br class=""></div><div apple-content-edited="true" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Actually not completely…Protocol does not handle properties storage. Only class (and struct) can be made abstract.</div><div apple-content-edited="true" class=""><br class=""></div><div apple-content-edited="true" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Doing this with protocol and class required the use of both and you need to enforce developer to inherit from class and implement protocol.. An abstract class encapsulate both on this in a single entity.</div>
<div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Here is a sample class for WebService :&nbsp;</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> WebService {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">private</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> lastModified : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSDate</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> url : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span>?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>lastModified<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSDate</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> performCall() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">url</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">lastModified</span>=<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSDate</span>()</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 class=""><br class=""></div><div class="">As written below, I can create a WebService instance…but I would like to forbid this because URL is a property that must be implemented by inherited classes.</div><div class=""><br class=""></div><div class="">I I use a protocol and Protocol extension, I will not be able to have lastModified stored value.</div><div class=""><br class=""></div><div class="">My proposal is to add abstract keyword as below :&nbsp;</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">abstract <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> WebService {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">private</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> lastModified : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSDate</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; abstract <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> url : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span>?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>lastModified<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSDate</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> performCall() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">url</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">lastModified</span>=<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSDate</span>()</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 class=""><br class=""></div><div class="">Then I will not be able to create a WebService object, and enforced to implement url property in inherited classes.</div><div class=""><br class=""></div><span class="Apple-tab-span" style="white-space:pre">        </span>Regards,<div class=""><br class=""></div><div class="">David</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 4 déc. 2015 à 09:43, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com" class="">griotspeak@gmail.com</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello David,<div class=""><br class=""></div><div class="">This sounds like something that can be accomplished with protocols and default implementations provided in protocol extensions. If you've watched&nbsp;<a href="https://developer.apple.com/videos/play/wwdc2015-408/" class="">Protocol-Oriented Programming in Swift [Session 408]</a>, slides 168 and on, once he begins talking about Protocol Extensions, is the relevant part. It looks like the functionality that you've described is already present in this feature.</div><div class=""><br class=""></div><div class="">TJ</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Dec 4, 2015 at 3:30 AM, David Scrève <span dir="ltr" class="">&lt;<a href="mailto:david.screve@dlta-studio.com" target="_blank" class="">david.screve@dlta-studio.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&nbsp; &nbsp; &nbsp; &nbsp; Hi Everyone,<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; Nice to see this new swift-evolution process….I’m not sure to completely understand the whole process of requesting evolutions, but I’m trying<br class="">
to do…<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; As I develop sort of framework, I usually have classes that I wanted to partially in the framework and force the user to implement others parts.<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; For example, I have a WebService class that manage the whole process to perform asynchronous call, error management.<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; This class has an abstract property that is specific for each WebService call.<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; Then I would like to make the URL property abstract and, consequently, the whole WebService class abstract : The WebService cannot be directly instantiated.<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; The goal of this feature would be to extend to method.<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; This behavior already exists in Java and is really useful.<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; The workaround is to make an URL property that returns invalid value or make assertion, but the error is only detected at runtime.<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; My proposal would be to just add a keyword before func, class or var. An abstract property or func should not provide implementation.<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; Regards,<br class="">
<br class="">
<br class="">
David<br class="">
<br class="">
<br class="">
<br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>