<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 class="">I agree.</div><div class=""><br class=""></div><div class="">While there may be specific cases where super must be called first or last, I think the examples provided were exceptions, rather than rules. The dealloc method in Obj-C for example was one case, and it was so overarching that the compiler took control of that with ARC.</div><div class=""><br class=""></div><div class="">I fail to see in mainstream code why it would ever be necessary to <i class="">force</i>&nbsp;a programmer not to do a single line of work prior, or prior to the end of, a super call. Could there be exceptions? I’m sure we could eventually find a use case. But I don’t think this is prolific enough that we need to start adding to the language for it. We can document the requirement on the method if we need to.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 26 Feb 2016, at 7:38 AM, Vanderlei Martinelli 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=""><div dir="ltr" class="">I vote (again) to only specify if a func requires super. When to call super is up to the developer after reading the docs.<div class=""><br class=""></div><div class="">-Van</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Feb 25, 2016 at 5:02 PM, Jean-Daniel Dupas via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</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=""><div class="h5"><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 25 févr. 2016 à 20:28, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt; a écrit :</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 25, 2016, at 1:23 PM, Jean-Daniel Dupas &lt;<a href="mailto:mailing@xenonium.com" target="_blank" class="">mailing@xenonium.com</a>&gt; wrote:</div><br class=""><div class=""><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class="">Le 25 févr. 2016 à 20:19, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; a écrit :<br class=""><br class=""><br class=""><br class="">Sent from my iPad<br class=""><br class=""><blockquote type="cite" class="">On Feb 25, 2016, at 1:17 PM, Jean-Daniel Dupas via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">Le 25 févr. 2016 à 16:47, Jeremy Pereira via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; a écrit :<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 17 Feb 2016, at 22:26, Kyle Sherman via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Thanks for the replies.<br class=""><br class="">Kenny: After thinking about it more, discussing with Peter, and looking Haravikk’s comments, I think the best thing would be for this to be a warning as suggested. I respectfully disagree that as a library creator you would not be able to know that a call to super should be required.<br class=""></blockquote><br class="">I disagree. You can’t possibly know all the use-cases in which your class might be subclassed.<span class="">&nbsp;</span><br class=""><br class="">In particular, it is absurd to enforce having the call to super as the first or last line of the method. That would stop me doing things like this:<br class=""><br class="">override func viewDidLoad()<br class="">{<br class="">&nbsp;&nbsp;&nbsp;&nbsp;print(“About to run super.viewDidLoad()”)<br class="">&nbsp;&nbsp;&nbsp;&nbsp;super.viewDidLoad()<br class="">&nbsp;&nbsp;&nbsp;&nbsp;print(“Finished super.viewDidLoad()”)<br class="">}<br class=""><br class="">Then there’s the perfectly reasonable case like this:<br class=""><br class="">override func viewDidLoad()<br class="">{<br class="">&nbsp;&nbsp;&nbsp;&nbsp;functionThatCallsSuperViewDidLoad()<br class="">}<br class=""><br class="">Why shouldn’t I be allowed to do that?<br class=""></blockquote><br class="">+1 with your concern. I’d be curious to see a single real world use case where enforcing first or last is required.<br class=""></blockquote><br class="">I posted several examples from Apple frameworks in an old thread about this.&nbsp; You might want to look for that message in the archives.<br class=""></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">And not a single one has a strong requirement about prohibiting code to be call before or after the super class implementation.</span></div></blockquote><br class=""></div><div class="">It depends what you mean by “strong”.&nbsp; Sure, a log statement won’t make much difference.&nbsp; But the examples I gave do have semantic requirements that super should either go first or last in performing real work to be done by the method.</div></div></div></blockquote><br class=""></div></div></div><div class="">For instance:</div><div class=""><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)" class="">// If you override this method, you must call super first to get the invalidation context object to return. After getting this object, set any custom properties and return it.
func invalidationContextForBoundsChange(_ newBounds: CGRect) -&gt; UICollectionViewLayoutInvalidationContext</pre><div class=""><br class=""></div><div class="">Why must I call super first ? Why can’t I don’t a bunch of things that are related to my subclass first ?</div><div class=""><br class=""></div><div class="">How am I supposed to do if I want to compute a new bound to pass to super instead of forwarding it naively.</div><div class=""><br class=""></div><div class="">ditto for&nbsp;</div><div class=""><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)" class="">// call super first to retrieve the item’s existing attributes and then make your changes to the returned structure.
layoutAttributesForInteractivelyMovingItemAtIndexPath(_ indexPath: NSIndexPath, withTargetPosition position: CGPoint) -&gt; UICollectionViewLayoutAttributes</pre><div class="">Why would you prevent a subclass to compute an other indexPath or target position before calling super ?</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""></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>
_______________________________________________<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=""></body></html>