<div dir="ltr">Not that I disagree with having a superclass overly dictate what a subclass can do... it can quickly become a double edges sword however it can be powerful for complex class designs especially if they focus on extension via subclassing.<div><br></div><div>It should be noted it isn&#39;t always possible to leverage the super class calling a final method as a point of enforcement. If the interface is public then any code could call an overridden function without the ability for the super class to enforce desired requirements. (yeah you could likely achieve this by having the overridables have non-public access)</div><div><br></div><div>Anyway some more thinking out loud...</div><div><br></div><div>sub-class:</div><div><br></div><div>override -&gt; implies that the subclass intends to override a function of its super class chain, if no such function is found up the chain at compile time then a compiler error can be omitted to help catch missed function signature changes that affect a sub-class (or fat fingering of a function name), if absent and an override is taking place the compiler could also flag unexpected override (e.g. function signature collision).</div><div><br></div><div>override with no qualifier is assumed to imply the overriding code should at some point call up to the supers implementation, if that isn&#39;t found the compiler should provide a fixup to either add the (instead) qualifier to make it clear you want to replace the supers implementation or force you to add a call to super</div><div><br></div><div>override(before) &amp; override(after) could exist to help catch errors and/or generate code as needed (super call not needed in the overriding)</div><div><br></div><div>override func foo() {...}</div><div>override(instead|before|after) func bar() {...} </div><div><br></div><div>super-class:</div><div><br></div><div>require -&gt; implies some requirement for those subclassing the function</div><div><br></div><div>require(override) -&gt; implies that a subclass must override and that the class stating this requirement should be considered abstract</div><div><br></div><div>require(super) -&gt; states that any override must call supers implementation at some point in its body, override(instead) wouldn&#39;t be allowed, if the requirement is not specified the subclass is free to call or not call the supers implementation<br></div><div><br></div><div>require(superBefore) -&gt; states that it is expected that a subclass calls super before doing things in its override, if the subclass doesn&#39;t doesn&#39;t honor this requirement the compiler will help to enforce it however a subclass could state it is explicitly ignoring that requirement by say something like override(ignoreBefore), override(instead) wouldn&#39;t be allowed, consider this an escape hatch for subclasses,</div><div><br></div><div>require(superAfter) -&gt; same as above but after the override body</div><div><br></div><div>Note something like require(override, superXxx) is valid allowing for a base class to provide some amount of implementation while still being considered an abstract class.</div><div><br></div><div>final func baz() {...}</div><div>require(override) func foo() {}<br></div><div>require(override, super|superBefore|superAfter) func bar() {...}</div><div><br></div><div>Note I have not convinced myself of the true need for something like this but I see being a potential benefit for class authors.</div><div><br></div><div>-Shawn</div><div><br><div><br><div class="gmail_quote"><div dir="ltr">On Tue, Feb 16, 2016 at 6:51 AM Sean Heber via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Agreed - attempting to enforce the ordering is too fiddly and complicated, IMO. If the superclass must ensure a specific order, then it should do so itself by first calling a final function that then calls the overridable function at the right time.<br>
</blockquote></div></div></div></div>