<div dir="ltr">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><br></div><div>-Van</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 25, 2016 at 5:02 PM, Jean-Daniel Dupas via swift-evolution <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><div class="h5"><br><div><blockquote type="cite"><div>Le 25 févr. 2016 à 20:28, Matthew Johnson <<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.com</a>> a écrit :</div><br><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Feb 25, 2016, at 1:23 PM, Jean-Daniel Dupas <<a href="mailto:mailing@xenonium.com" target="_blank">mailing@xenonium.com</a>> wrote:</div><br><div><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"><br>Le 25 févr. 2016 à 20:19, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> a écrit :<br><br><br><br>Sent from my iPad<br><br><blockquote type="cite">On Feb 25, 2016, at 1:17 PM, Jean-Daniel Dupas via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br><br><blockquote type="cite">Le 25 févr. 2016 à 16:47, Jeremy Pereira via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> a écrit :<br><br><br><blockquote type="cite">On 17 Feb 2016, at 22:26, Kyle Sherman via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br>Thanks for the replies.<br><br>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></blockquote><br>I disagree. You can’t possibly know all the use-cases in which your class might be subclassed.<span> </span><br><br>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><br>override func viewDidLoad()<br>{<br> print(“About to run super.viewDidLoad()”)<br> super.viewDidLoad()<br> print(“Finished super.viewDidLoad()”)<br>}<br><br>Then there’s the perfectly reasonable case like this:<br><br>override func viewDidLoad()<br>{<br> functionThatCallsSuperViewDidLoad()<br>}<br><br>Why shouldn’t I be allowed to do that?<br></blockquote><br>+1 with your concern. I’d be curious to see a single real world use case where enforcing first or last is required.<br></blockquote><br>I posted several examples from Apple frameworks in an old thread about this. You might want to look for that message in the archives.<br></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"><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">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></div><div>It depends what you mean by “strong”. Sure, a log statement won’t make much difference. 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></div></div></div><div>For instance:</div><div><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)">// 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) -> UICollectionViewLayoutInvalidationContext</pre><div><br></div><div>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><br></div><div>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><br></div><div>ditto for </div><div><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)">// 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) -> UICollectionViewLayoutAttributes</pre><div>Why would you prevent a subclass to compute an other indexPath or target position before calling super ?</div></div><div><br></div><div><br></div><div><br></div></div><br></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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></div>