<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 want to say +1.</div><div class=""><br class=""></div><div class="">Ruby does this and it works really nicely. While not a big deal in simple cases, when a method has lots of arguments, it’s just really noisy.</div><div class=""><br class=""></div><div class="">There’s a problem though. If `super` means both “call the superclass’s implementation of this method”, and “the superclass”, there’s a potential for ambiguity.</div><div class=""><br class=""></div><div class="">Say:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">override</span> <span class="" style="color: rgb(187, 44, 162);">var</span> widgetCount: <span class="" style="color: rgb(112, 61, 170);">Int</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(187, 44, 162);">return</span> <span class="" style="color: rgb(187, 44, 162);">super</span>.widgetCount + <span class="" style="color: rgb(39, 42, 216);">5</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div></div></div></div></div></blockquote><br class=""></div><div class="">And:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">extension Int {</div><div class=""> var widgetCount: Int { return 10 }</div><div class="">}</div></blockquote><div class=""><br class=""></div><div class="">Does <span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">super</span><span style="font-family: Menlo; font-size: 11px;" class="">.widgetCount</span> call the superclass’s `widgetCount`, or does it call the superclass’s implementation of the same getter, then call `widgetCount` on the returned Int?</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 09 Feb 2016, at 06:31, Petroules Jake via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hello,
<div class=""><br class="">
</div>
<div class="">I have a language syntax proposal. I've read the Swift evolution guidelines and hopefully this is the proper way to start. So, my proposal is:</div>
<div class=""><br class="">
</div>
<div class="">Permit a shorthand syntax for invoking the supertype implementation of a property or function. A single statement 'super' is equivalent to invoking the supertype implementation, forwarding the arguments unchanged, and returning the result. For
example, the following samples:</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: rgb(187, 44, 162);" class="">override</span> <span style="color: rgb(187, 44, 162);" class="">func</span> mouseEntered(theEvent: <span style="color: rgb(112, 61, 170);" class="">NSEvent</span>) {</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="color: rgb(187, 44, 162);" class="">super</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="color: rgb(49, 89, 93);" class="">handleMouseEvent</span>(theEvent)</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
}</div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">override</span> <span style="color: rgb(187, 44, 162);" class="">func</span> specialValue(key: <span style="color: rgb(112, 61, 170);" class="">String</span>)
-> <span style="color: rgb(112, 61, 170);" class="">Int</span> {</div>
<div style="margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class="">
<span style="" class=""> </span>return<span style="" class=""> </span>super<span style="" class=""> + </span><span style="color: rgb(39, 42, 216);" class="">1</span></div>
<div style="margin: 0px; line-height: normal;" class="">}</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">override</span> <span style="color: rgb(187, 44, 162);" class="">var</span> widgetCount: <span style="color: rgb(112, 61, 170);" class="">Int</span> {</div>
<div style="margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class="">
<span style="" class=""> </span>return<span style="" class=""> </span>super<span style="" class=""> + </span><span style="color: rgb(39, 42, 216);" class="">5</span></div>
<div style="margin: 0px; line-height: normal;" class="">}</div>
</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class="">are exactly equivalent to the following samples:</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: rgb(187, 44, 162);" class="">override</span> <span style="color: rgb(187, 44, 162);" class="">func</span> mouseEntered(theEvent: <span style="color: rgb(112, 61, 170);" class="">NSEvent</span>) {</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="color: rgb(187, 44, 162);" class="">super</span>.<span style="color: rgb(61, 29, 129);" class="">mouseEntered</span>(theEvent)</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="color: rgb(49, 89, 93);" class="">handleMouseEvent</span>(theEvent)</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
}</div>
<div class="">
<div class=""><br class="webkit-block-placeholder">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">override</span> <span style="color: rgb(187, 44, 162);" class="">func</span> specialValue(key: <span style="color: rgb(112, 61, 170);" class="">String</span>)
-> <span style="color: rgb(112, 61, 170);" class="">Int</span> {</div>
<div style="margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">return</span> <span style="color: rgb(187, 44, 162);" class="">super</span>.specialValue(key) + <span style="color: rgb(39, 42, 216);" class="">1</span></div>
<div style="margin: 0px; line-height: normal;" class="">}</div>
</div>
</div>
<div class=""><br class="webkit-block-placeholder">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="color: rgb(187, 44, 162);" class="">override</span> <span style="color: rgb(187, 44, 162);" class="">var</span> widgetCount: <span style="color: rgb(112, 61, 170);" class="">Int</span> {</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<span style="color: rgb(187, 44, 162);" class="">return</span> <span style="color: rgb(187, 44, 162);" class="">super</span>.widgetCount + <span style="color: rgb(39, 42, 216);" class="">5</span></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
}</div>
</div>
<div class=""><br class="">
</div>
<div class="">Alternatives/complementary ideas:</div>
<div class=""><br class="">
</div>
<div class="">- Require `<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">super</span><span style="font-family: Menlo; font-size: 11px;" class="">()</span>` or `<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">super</span><span style="font-family: Menlo; font-size: 11px;" class="">(...)</span>`
syntax for invocations which are function calls, for consistency with other function calls in the language and/or to indicate that arguments are forwarded</div>
<div class=""><br class="">
</div>
<div class="">Looking forward to your feedback.</div>
<div class=""><br class="">
</div>
<div class="">Thanks!</div>
</div>
</div>
<div class="">
<div style="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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
-- <br class="">
Jake Petroules - <a href="mailto:jake.petroules@theqtcompany.com" class="">jake.petroules@theqtcompany.com</a><br class="">
Consulting Services Engineer - The Qt Company</div>
</div>
</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>