<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=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 22 févr. 2016 à 19:51, Kyle Sherman via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">## Detailed design</span><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break"><br class="kix-line-break"></span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">A possible implementation of this may look like this:</span></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">```</span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">class MyClass {</span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;"> &nbsp;&nbsp;&nbsp;@requiresSuper func foo1() { }</span></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;"> &nbsp;&nbsp;&nbsp;@requiresSuper(start) func foo2() { }</span></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;"> &nbsp;&nbsp;&nbsp;@requiresSuper(end) func foo3() { }</span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">}</span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">```</span></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">Now, if the developer were to create a subclass and not call the super method, the compiler should display a warning. The warnings that should be displayed should be similar to: </span></div><ol class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin-top: 0pt; margin-bottom: 0pt;"><li dir="ltr" class="" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline;"><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; vertical-align: baseline; white-space: pre-wrap;">Overridden method must call the superclass’s implementation</span></div></li><li dir="ltr" class="" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline;"><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; vertical-align: baseline; white-space: pre-wrap;">Overridden method must call the superclass’s implementation as the first line of the method.</span></div></li><li dir="ltr" class="" style="list-style-type: decimal; font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline;"><div class="" style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; vertical-align: baseline; white-space: pre-wrap;">Overridden method must call the superclass’s implementation as the last line of the method.</span></div></li></ol><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;"><span class="" style="font-size: 14.666666666666666px; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">for the cases of `@requiresSuper`, `@requiresSuper(start)`, and `@requiresSuper(end)` respectively.</span></div><br class="Apple-interchange-newline"></div></blockquote></div><br class=""><div class="">Been following the many discussions on this topic and I do not think &nbsp;that these start/end requirements will ever fly. Imposing such a specific location on the sub-classes will cause a lot of troubles, whether it being unable to add debug log, or to tweak parameters before passing them to super, in the end the developer of the main class won’t dare use such specification, to avoid pushing away potential sub-class developer, and as a way to preemptively mute their complaining.</div><div class=""><br class=""></div><div class="">OTOH, my guts are telling me that, some similar form of control may be desired on some occasion mainly when playing with resources, maybe for a setup-like method where super should be call before any other methods provided by the class, and or for close-like method, the reverse. &nbsp;Unfortunately, unless such rules are made rigid (all or nothing) such syntax would likely be too convoluted and long; super.close() must be call after super.read(), super.write(), ...</div><div class=""><br class=""></div><div class="">A possible syntax for the rigid rules would be:</div><div class=""><br class=""></div><div class="">@requiresSuper(before: methods)</div><div class="">@requiresSuper(after: methods, propertiesSetter)</div><div class=""><div class="">@requiresSuper(before: methods, propertiesGetter)</div></div><div class=""><br class=""></div><div class="">But, I do not have any examples in mind to corroborate that such options are better than the proposed @requiresSuper(start) and @requiresSuper(end). IMHO, I just think that @requiresSuper(start) and @requiresSuper(end) should be drop as too intransigent, which will cause them to be rarely used.</div><div class=""><br class=""></div><div class="">Dany</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>