<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=""><span class="Apple-tab-span" style="white-space:pre">        </span>Yes, <div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>I agree with you that abstract might be attached to protocol family of feature…but protocol already manage the ‘abstract’ feature if you don’t consider the value storage issue.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Actually, there 2 ways to add this feature : </div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>1 - Protocol way : We need to add value storage to protocol</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>2 - class way : We need to add abstract for method/properties</div><div class=""><br class=""><div apple-content-edited="true" class="">
<div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>The question is : Is adding value storage to protocol is a good thing ? It might create confusion between classes and protocol, maybe.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>But, on the other side, there is not real reason to limit class extension to only method and not to properties. In this case, extending protocol to value container might be an interesting way to respond to this. Anyway, we might keep the abstract keyword.</div></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Regards,</div><div class=""><br class=""></div><div class="">David</div><div class=""><br class=""></div></div><div><blockquote type="cite" class=""><div class="">Le 4 déc. 2015 à 10:11, T.J. Usiyan <<a href="mailto:griotspeak@gmail.com" class="">griotspeak@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hello,</div><div class=""><br class=""></div>This is an interesting example. I can't refute it without questioning decisions/intent rather than code so I'll just say that the `abstract` quality you're after still seems like it should be fit into the protocol family of features.<br class=""><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:56 AM, David Scrève <span dir="ltr" class=""><<a href="mailto:david.screve@dlta-studio.com" target="_blank" class="">david.screve@dlta-studio.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span style="white-space:pre-wrap" class="">        </span>Hello TJ,</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class="">        </span>Actually not completely…Protocol does not handle properties storage. Only class (and struct) can be made abstract.</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class="">        </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 style="white-space:pre-wrap" class="">        </span>Here is a sample class for WebService : </div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">class</span> WebService {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#bb2ca2" class="">private</span> <span style="color:#bb2ca2" class="">var</span> lastModified : <span style="color:#703daa" class="">NSDate</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#bb2ca2" class="">var</span> url : <span style="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=""> <span style="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="" class=""> </span>lastModified<span style="" class="">=</span><span style="color:#703daa" class="">NSDate</span><span style="" class="">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> }</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=""> <span style="color:#bb2ca2" class="">func</span> performCall() {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#3d1d81" class="">print</span>(<span style="color:#bb2ca2" class="">self</span>.<span style="color:#4f8187" class="">url</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#bb2ca2" class="">self</span>.<span style="color:#4f8187" class="">lastModified</span>=<span style="color:#703daa" class="">NSDate</span>()</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> }</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 : </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="color:#bb2ca2" class="">class</span> WebService {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#bb2ca2" class="">private</span> <span style="color:#bb2ca2" class="">var</span> lastModified : <span style="color:#703daa" class="">NSDate</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> abstract <span style="color:#bb2ca2" class="">var</span> url : <span style="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=""> <span style="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="" class=""> </span>lastModified<span style="" class="">=</span><span style="color:#703daa" class="">NSDate</span><span style="" class="">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> }</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=""> <span style="color:#bb2ca2" class="">func</span> performCall() {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#3d1d81" class="">print</span>(<span style="color:#bb2ca2" class="">self</span>.<span style="color:#4f8187" class="">url</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#bb2ca2" class="">self</span>.<span style="color:#4f8187" class="">lastModified</span>=<span style="color:#703daa" class="">NSDate</span>()</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> }</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 style="white-space:pre-wrap" class="">        </span>Regards,<div class=""><br class=""></div><div class="">David</div><div class=""><div class="h5"><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 4 déc. 2015 à 09:43, T.J. Usiyan <<a href="mailto:griotspeak@gmail.com" target="_blank" class="">griotspeak@gmail.com</a>> a écrit :</div><br class=""><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 <a href="https://developer.apple.com/videos/play/wwdc2015-408/" target="_blank" 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=""><<a href="mailto:david.screve@dlta-studio.com" target="_blank" class="">david.screve@dlta-studio.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi Everyone,<br class="">
<br class="">
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="">
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="">
For example, I have a WebService class that manage the whole process to perform asynchronous call, error management.<br class="">
This class has an abstract property that is specific for each WebService call.<br class="">
<br class="">
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="">
The goal of this feature would be to extend to method.<br class="">
This behavior already exists in Java and is really useful.<br class="">
<br class="">
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="">
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="">
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" target="_blank" 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></div></div></div><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>