<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="">Now you have two new/magic behaviors:</div><div class=""><br class=""></div><div class="">- `super` meaning “super.thisMethod”, and</div><div class="">- #args copying the arguments of the current call</div><div class=""><br class=""></div><div class="">While `#args` may possibly be useful somewhere, it seems orthogonal to this proposal, and it seems simpler to go with `super()`.</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 09 Feb 2016, at 11:39, James Campbell &lt;<a href="mailto:james@supmenow.com" class="">james@supmenow.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">What if we could use the compiler to help ?<div class=""><br class=""></div><div class="">super(#args)&nbsp;</div><div class=""><br class=""></div><div class="">#args being the arguments passed to the current function.</div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Lead Engineer</b></p><p class=""><b class=""><font color="#cc0000" class=""><a href="mailto:james@supmenow.com" target="_blank" class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Tue, Feb 9, 2016 at 9:09 AM, Radosław Pietruszewski <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=""><span class=""><div class=""><blockquote type="cite" class=""><div style="word-wrap:break-word" class="">`super` would only exhibit the proposed behavior when it is a standalone token. The expressions `super` and `super.widgetCount` are both permitted and both are exactly equivalent.<div class=""><br class=""></div><div class="">To express what you're suggesting with the extension (either with the current grammar or the proposed feature), it would be:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">override var widgetCount: Int {</font></div><div class=""><font face="Courier New" class="">&nbsp; &nbsp; return super.widgetCount.widgetCount + 5</font></div><div class=""><font face="Courier New" class="">}</font></div><div class=""><br class=""></div><div class="">Your example is not ambiguous because `super.widgetCount` only ever means the value of the widgetCount property in the superclass; `super` is not first evaluated to the aforementioned value and then `widgetCount` invoked on that result, since the entire `super.widgetCount` would be treated atomically, conceptually, as it is now.</div></div></blockquote><br class=""></div></span><div class="">Maybe, but I don’t like it. Even if the compiler can disambiguate, this will still be confusing.</div><span class=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">Without offering an opinion either way on this proposal, I will note that the alternative suggestion of `super()` does not suffer from this ambiguity.</blockquote></div><div class=""><br class=""></div></span><div class="">You’re right! I’d be cool with `super()`.</div><br class=""><div class="">
<div class="">— Radek</div>
</div><div class=""><div class="h5">
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On 09 Feb 2016, at 09:44, Petroules Jake &lt;<a href="mailto:Jake.Petroules@theqtcompany.com" target="_blank" class="">Jake.Petroules@theqtcompany.com</a>&gt; wrote:</div><br class=""><div class="">



<div style="word-wrap:break-word" class="">
`super` would only exhibit the proposed behavior when it is a standalone token. The expressions `super` and `super.widgetCount` are both permitted and both are exactly equivalent.
<div class=""><br class="">
</div>
<div class="">To express what you're suggesting with the extension (either with the current grammar or the proposed feature), it would be:</div>
<div class=""><br class="">
</div>
<div class=""><font face="Courier New" class="">override var widgetCount: Int {</font></div>
<div class=""><font face="Courier New" class="">&nbsp; &nbsp; return super.widgetCount.widgetCount + 5</font></div>
<div class=""><font face="Courier New" class="">}</font></div>
<div class=""><br class="">
</div>
<div class="">Your example is not ambiguous because `super.widgetCount` only ever means the value of the widgetCount property in the superclass; `super` is not first evaluated to the aforementioned value and then `widgetCount` invoked on that result, since
 the entire `super.widgetCount` would be treated atomically, conceptually, as it is now.</div>
<div class=""><br class="">
</div>
<div class="">I can see that the fact that `super` itself does refer to an instance of T could be problematic for properties. For functions, if written as `super()` or `super(...)` so this should be OK and unambiguous. Perhaps the shorthand syntax could be
 limited to functions since they tend to be longer and in greater need of something like this in the first place.</div>
<div class="">
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Feb 9, 2016, at 12:28 AM, Radosław Pietruszewski &lt;<a href="mailto:radexpl@gmail.com" target="_blank" class="">radexpl@gmail.com</a>&gt; wrote:</div>
<br class="">
<div class="">
<div style="word-wrap:break-word" class="">
<div class="">I want to say +1.</div>
<div class=""><br class="">
</div>
<div class="">Ruby does this and it works really nicely.&nbsp; 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 style="word-wrap:break-word" class="">
<div class="">
<div class="">
<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>&nbsp;<span style="color:rgb(187,44,162)" class="">var</span>&nbsp;widgetCount:&nbsp;<span style="color:rgb(112,61,170)" class="">Int</span>&nbsp;{</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">
&nbsp; &nbsp;&nbsp;<span style="color:rgb(187,44,162)" class="">return</span>&nbsp;<span style="color:rgb(187,44,162)" class="">super</span>.widgetCount +&nbsp;<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>
</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="">&nbsp; &nbsp; var widgetCount: Int { return 10 }</div>
<div class="">}</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Does&nbsp;<span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)" class="">super</span><span style="font-family:Menlo;font-size:11px" class="">.widgetCount</span>&nbsp;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 class="">
<blockquote type="cite" class="">
<div class="">On 09 Feb 2016, at 06:31, Petroules Jake via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div>
<br class="">
<div class="">
<div style="word-wrap:break-word" 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>&nbsp;<span style="color:rgb(187,44,162)" class="">func</span>&nbsp;mouseEntered(theEvent:&nbsp;<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="">
&nbsp; &nbsp;&nbsp;<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="">
&nbsp; &nbsp;&nbsp;<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>&nbsp;<span style="color:rgb(187,44,162)" class="">func</span>&nbsp;specialValue(key:&nbsp;<span style="color:rgb(112,61,170)" class="">String</span>)
 -&gt;&nbsp;<span style="color:rgb(112,61,170)" class="">Int</span>&nbsp;{</div>
<div style="margin:0px;line-height:normal;color:rgb(187,44,162)" class="">
<span class="">&nbsp; &nbsp;&nbsp;</span>return<span class="">&nbsp;</span>super<span class="">&nbsp;+&nbsp;</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>&nbsp;<span style="color:rgb(187,44,162)" class="">var</span>&nbsp;widgetCount:&nbsp;<span style="color:rgb(112,61,170)" class="">Int</span>&nbsp;{</div>
<div style="margin:0px;line-height:normal;color:rgb(187,44,162)" class="">
<span class="">&nbsp; &nbsp;&nbsp;</span>return<span class="">&nbsp;</span>super<span class="">&nbsp;+&nbsp;</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>&nbsp;<span style="color:rgb(187,44,162)" class="">func</span>&nbsp;mouseEntered(theEvent:&nbsp;<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="">
&nbsp; &nbsp;&nbsp;<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="">
&nbsp; &nbsp;&nbsp;<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="">
</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>&nbsp;<span style="color:rgb(187,44,162)" class="">func</span>&nbsp;specialValue(key:&nbsp;<span style="color:rgb(112,61,170)" class="">String</span>)
 -&gt;&nbsp;<span style="color:rgb(112,61,170)" class="">Int</span>&nbsp;{</div>
<div style="margin:0px;line-height:normal" class="">&nbsp; &nbsp;&nbsp;<span style="color:rgb(187,44,162)" class="">return</span>&nbsp;<span style="color:rgb(187,44,162)" class="">super</span>.specialValue(key) +&nbsp;<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="">
</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>&nbsp;<span style="color:rgb(187,44,162)" class="">var</span>&nbsp;widgetCount:&nbsp;<span style="color:rgb(112,61,170)" class="">Int</span>&nbsp;{</div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">
&nbsp; &nbsp;&nbsp;<span style="color:rgb(187,44,162)" class="">return</span>&nbsp;<span style="color:rgb(187,44,162)" class="">super</span>.widgetCount +&nbsp;<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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="">
--&nbsp;<br class="">
Jake Petroules -&nbsp;<a href="mailto:jake.petroules@theqtcompany.com" target="_blank" class="">jake.petroules@theqtcompany.com</a><br class="">
Consulting Services Engineer -&nbsp;The Qt Company</div>
</div>
</div>
<br class="">
</div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
<div class="">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="">
--&nbsp;<br class="">
Jake Petroules -&nbsp;<a href="mailto:jake.petroules@theqtcompany.com" target="_blank" class="">jake.petroules@theqtcompany.com</a><br class="">
Consulting Services Engineer -&nbsp;The Qt Company</div>
</div>
</div>
<br class="">
</div>
</div>
</div>

</div></blockquote></div><br class=""></div></div></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>
</div></blockquote></div><br class=""></body></html>