<p dir="ltr">Jo, maybe it&#39;s time to explore infix functions as a potential solution? I don&#39;t see infix functions under the commonly proposed list. </p>
<br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 8, 2016, 4:28 PM Jo Albright 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"><div style="word-wrap:break-word">I promise, this is my last idea to be thrown at this. Instead of characters in operators...<div><br></div><div>Would the core team be open to having an <b>operatoralias</b> keyword that allows an operator to be masked by an identifier.</div><div><br></div><div>Learning &amp; Teaching Example :</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span style="color:rgb(0,0,0)"><br></span></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">operatoralias<span style="color:rgb(0,0,0)"> plus = +</span></div></div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px"><br></span></div><div style="margin:0px;line-height:normal"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> apples = <span style="color:rgb(39,42,216)">5</span> + <span style="color:rgb(39,42,216)">5</span></div></div></div></div><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">let</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">apples =</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">5</span><span style="font-family:Menlo;font-size:11px"> plus</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">5</span><div><font color="#272ad8" face="Menlo"><span style="font-size:11px"><br></span></font></div><div>With extension :</div><div><br></div><div><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">let</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">apples</span><span style="font-family:Menlo;font-size:11px"> = </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">5</span><span style="font-family:Menlo;font-size:11px"> . </span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">plus </span><span style="font-family:Menlo;font-size:11px">( </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">5</span><span style="font-family:Menlo;font-size:11px"> )</span></div><div><br></div><div>---------------------------------------------------------------------------------</div><div><div><br></div><div>Learning &amp; Teaching Example :</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">operatoralias<span style="color:#000000"> </span><span style="color:rgb(0,0,0)">incrementedBy</span><span style="color:#000000"> = +=</span></div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">updatedValue<span style="color:#000000"> += </span><span style="color:#272ad8">10</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">updatedValue<span style="color:#000000"> </span><span style="color:rgb(0,0,0)">incrementedBy</span><span style="color:#000000"> </span><span style="color:#272ad8">10</span></div></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">With extension :</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="color:rgb(79,129,135);font-family:Menlo;font-size:11px">updatedValue</span><span style="font-family:Menlo;font-size:11px"> . </span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">incrementedBy </span><span style="font-family:Menlo;font-size:11px">( <font color="#272ad8">10</font></span><span style="font-family:Menlo;font-size:11px"> )</span></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">---------------------------------------------------------------------------------</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">Readability &amp; Code Reduction Example :</div></div></div></div></div><div style="word-wrap:break-word"><div><div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:#bb2ca2">typealias</span><span style="color:#000000"> Point = (x: </span>CGFloat<span style="color:#000000">,y: </span>CGFloat<span style="color:#000000">)</span></div></div><div style="margin:0px;line-height:normal"><br></div></div></div></div></div><div style="word-wrap:break-word"><div><div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">infix<span style="color:#000000"> </span>operator<span style="color:#000000"> &gt;&gt;&gt;&gt; { }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">func</span> &gt;&gt;&gt;&gt; (lhs: <span style="color:#703daa">CGContextRef</span>?, rhs: <span style="color:rgb(79,129,135)">Point</span>) -&gt; <span style="color:rgb(112,61,170)">CGContextRef</span>? {</div></div></div></div></div></div><div style="word-wrap:break-word"><div><div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#3d1d81">CGContextMoveToPoint</span>(lhs, rhs.<font color="#703daa">x</font>, rhs.<font color="#703daa">y</font>); <span style="color:rgb(187,44,162)">return </span>lhs</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div></div></div></div></div><div style="word-wrap:break-word"><div><div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"></div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">operatoralias</span><font face="Menlo"><span style="font-size:11px"> moveTo = &gt;&gt;&gt;&gt; </span></font><font color="#008400" face="Menlo"><span style="font-size:11px">// operator alias for custom operator</span></font></div></div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(61,29,129)"><span style="color:#bb2ca2">let</span><span style="color:#000000"> context = </span>UIGraphicsGetCurrentContext<span style="color:#000000">()</span></div></div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(61,29,129)"><span style="color:rgb(79,129,135)">context</span><span style="color:#000000"> moveTo </span>(<span style="color:rgb(39,42,216)">10</span>,<span style="color:rgb(39,42,216)">10</span>) addLineTo (2<span style="color:rgb(39,42,216)">0</span>,2<span style="color:rgb(39,42,216)">0</span>) strokeWith <span style="color:rgb(112,61,170)">UIColor</span>.redColor()</div></div><div><br></div><div>Or if SVG letters used (less readable, but also less footprint) :</div><div><br></div><div><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">context</span><span style="font-family:Menlo;font-size:11px"> M </span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">,</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">) L </span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">(2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">,2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">) stroke </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">UIColor</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">.</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">redColor()</span></div><div><br></div><div>I know this looks a lot like a chained method and very close to the same amount of code to be written… however it is slightly easier to read without all of the function punctuation in between :</div><div><br></div><div><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">context</span><span style="font-family:Menlo;font-size:11px">.moveTo</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">,</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">)?.addLineTo</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">(2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">,2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">)?.strokeWith.(</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">UIColor</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">.</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">redColor())</span></div><div><br></div><div><br></div><div>I believe there is an opportunity here that won’t truly be appreciated until it is in use. But will not argue that it is very close to what is currently available and does not have a huge impact in the current vision of things.</div><div><br></div><div>Thanks for humoring my imagination. :) </div></div></div></div><div style="word-wrap:break-word"><div><div><div><br></div><div><br></div><div><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"><font color="#8d8d8d"><span> </span>Nerd . Designer . Developer</font></span><font color="#464646"><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">Jo Albright</span></font><br style="color:rgb(0,0,0);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 style="color:rgb(0,0,0);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">
</div>
<br></div></div></div><div style="word-wrap:break-word"><div><div><div><blockquote type="cite"><div>On Jan 8, 2016, at 2:26 PM, Chris Lattner &lt;<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>&gt; wrote:</div><br><div><div><br><blockquote type="cite">On Jan 7, 2016, at 9:49 PM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>&gt; wrote:<br><br>Some other languages provide special syntax to use a binary function as infix:<br><br><br>Haskell:<br>    foo a b    -- is equivalent to<br>    a `foo` b<br><br>Mathematica:<br>    Foo[a, b]  (*is equivalent to*)<br>    a~Foo~b<br></blockquote><br>Ok, then yes, introducing a magic syntax would be technically feasible (though not backticks, since they are used for something else).<br><br>This is still extremely unlikely to be accepted though.  Additional language complexity needs to pay for itself, and the win here is so small that it doesn’t seem worth it.<br><br>-Chris<br><br></div></div></blockquote></div><br></div></div></div><div style="word-wrap:break-word"><div><div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=8CZIdLciSFC-2BO5jF-2FiP8qN7dBFsgCUZ50wdTsolcRPcEmhP8zqcLl0BiyM8aEFtlIyoSNLzZKyz7AnwH2lWx8DFyCnjXphQhqkIIVikLfRJB6kOkIVFh5cFUcRXGqQRRl-2BR8DbsbiNN7cgxFN1J2dSZcxalKvGD64V4iA0wWw-2BKCUBPALcJj2-2BAD2xf0VvW2M4pN8aa0nu5TJldW2wAD6ogJojEuyKDgX4jOj3nK-2BCY-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">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>
</blockquote></div>