<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="">On Jan 8, 2016, at 2:43 PM, Dennis Lysenko <<a href="mailto:dennis.s.lysenko@gmail.com" class="">dennis.s.lysenko@gmail.com</a>> wrote:</div><div class=""><p dir="ltr" class="">Jo, maybe it's time to explore infix functions as a potential solution? I don't see infix functions under the commonly proposed list. </p></div></blockquote><div>I just added them. To repeat what has been said several times on this thread, the problem being solved here is not important enough to be worth complicating the language for.</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class="">
<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Jan 8, 2016, 4:28 PM Jo Albright via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></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" class="">I promise, this is my last idea to be thrown at this. Instead of characters in operators...<div class=""><br class=""></div><div class="">Would the core team be open to having an <b class="">operatoralias</b> keyword that allows an operator to be masked by an identifier.</div><div class=""><br class=""></div><div class="">Learning & Teaching Example :</div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)" class=""><span style="" class=""><br class=""></span></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)" class="">operatoralias<span style="" class=""> plus = +</span></div></div><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;line-height:normal" class=""><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px" class=""><br class=""></span></div><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">let</span> apples = <span style="color:rgb(39,42,216)" class="">5</span> + <span style="color:rgb(39,42,216)" class="">5</span></div></div></div></div><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)" class="">let</span><span style="font-family:Menlo;font-size:11px" class=""> </span><span style="font-family:Menlo;font-size:11px" class="">apples =</span><span style="font-family:Menlo;font-size:11px" class=""> </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">5</span><span style="font-family:Menlo;font-size:11px" class=""> plus</span><span style="font-family:Menlo;font-size:11px" class=""> </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">5</span><div class=""><font color="#272ad8" face="Menlo" class=""><span style="font-size:11px" class=""><br class=""></span></font></div><div class="">With extension :</div><div class=""><br class=""></div><div class=""><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)" class="">let</span><span style="font-family:Menlo;font-size:11px" class=""> </span><span style="font-family:Menlo;font-size:11px" class="">apples</span><span style="font-family:Menlo;font-size:11px" class=""> = </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">5</span><span style="font-family:Menlo;font-size:11px" class=""> . </span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)" class="">plus </span><span style="font-family:Menlo;font-size:11px" class="">( </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">5</span><span style="font-family:Menlo;font-size:11px" class=""> )</span></div><div class=""><br class=""></div><div class="">---------------------------------------------------------------------------------</div><div class=""><div class=""><br class=""></div><div class="">Learning & Teaching Example :</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)" class="">operatoralias<span style="" class=""> </span><span style="" class="">incrementedBy</span><span style="" class=""> = +=</span></div><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class="">updatedValue<span style="" class=""> += </span><span style="color:#272ad8" class="">10</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class="">updatedValue<span style="" class=""> </span><span style="" class="">incrementedBy</span><span style="" class=""> </span><span style="color:#272ad8" class="">10</span></div></div><div style="margin:0px;line-height:normal" class=""><br class=""></div><div style="margin:0px;line-height:normal" class="">With extension :</div><div style="margin:0px;line-height:normal" class=""><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="color:rgb(79,129,135);font-family:Menlo;font-size:11px" class="">updatedValue</span><span style="font-family:Menlo;font-size:11px" class=""> . </span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)" class="">incrementedBy </span><span style="font-family:Menlo;font-size:11px" class="">( <font color="#272ad8" class="">10</font></span><span style="font-family:Menlo;font-size:11px" class=""> )</span></div><div style="margin:0px;line-height:normal" class=""><br class=""></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="">Readability & Code Reduction Example :</div></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;line-height:normal" class=""><br class=""></div><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)" class=""><span style="color:#bb2ca2" class="">typealias</span><span style="" class=""> Point = (x: </span>CGFloat<span style="" class="">,y: </span>CGFloat<span style="" class="">)</span></div></div><div style="margin:0px;line-height:normal" class=""><br class=""></div></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)" class="">infix<span style="" class=""> </span>operator<span style="" class=""> >>>> { }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">func</span> >>>> (lhs: <span style="color:#703daa" class="">CGContextRef</span>?, rhs: <span style="color:rgb(79,129,135)" class="">Point</span>) -> <span style="color:rgb(112,61,170)" class="">CGContextRef</span>? {</div></div></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="margin:0px;line-height:normal" class=""><div style="margin:0px;line-height:normal" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""> <span style="color:#3d1d81" class="">CGContextMoveToPoint</span>(lhs, rhs.<font color="#703daa" class="">x</font>, rhs.<font color="#703daa" class="">y</font>); <span style="color:rgb(187,44,162)" class="">return </span>lhs</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div></div></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="margin:0px;line-height:normal" class=""><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=""><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px" class="">operatoralias</span><font face="Menlo" class=""><span style="font-size:11px" class=""> moveTo = >>>> </span></font><font color="#008400" face="Menlo" class=""><span style="font-size:11px" class="">// operator alias for custom operator</span></font></div></div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(61,29,129)" class=""><span style="color:#bb2ca2" class="">let</span><span style="" class=""> context = </span>UIGraphicsGetCurrentContext<span style="" class="">()</span></div></div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(61,29,129)" class=""><span style="color:rgb(79,129,135)" class="">context</span><span style="" class=""> moveTo </span>(<span style="color:rgb(39,42,216)" class="">10</span>,<span style="color:rgb(39,42,216)" class="">10</span>) addLineTo (2<span style="color:rgb(39,42,216)" class="">0</span>,2<span style="color:rgb(39,42,216)" class="">0</span>) strokeWith <span style="color:rgb(112,61,170)" class="">UIColor</span>.redColor()</div></div><div class=""><br class=""></div><div class="">Or if SVG letters used (less readable, but also less footprint) :</div><div class=""><br class=""></div><div class=""><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)" class="">context</span><span style="font-family:Menlo;font-size:11px" class=""> M </span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">,</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">) L </span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">(2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">,2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">) stroke </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)" class="">UIColor</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">.</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">redColor()</span></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)" class="">context</span><span style="font-family:Menlo;font-size:11px" class="">.moveTo</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">,</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">10</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">)?.addLineTo</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">(2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">,2</span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">0</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">)?.strokeWith.(</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)" class="">UIColor</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">.</span><span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px" class="">redColor())</span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Thanks for humoring my imagination. :) </div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><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" class=""><font color="#8d8d8d" class=""><span class=""> </span>Nerd . Designer . Developer</font></span><font color="#464646" class=""><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" class=""><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" class="">Jo Albright</span></font><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;" class=""><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;" class="">
</div>
<br class=""></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2016, at 2:26 PM, Chris Lattner <<a href="mailto:clattner@apple.com" target="_blank" class="">clattner@apple.com</a>> wrote:</div><br class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">On Jan 7, 2016, at 9:49 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>> wrote:<br class=""><br class="">Some other languages provide special syntax to use a binary function as infix:<br class=""><br class=""><br class="">Haskell:<br class=""> foo a b -- is equivalent to<br class=""> a `foo` b<br class=""><br class="">Mathematica:<br class=""> Foo[a, b] (*is equivalent to*)<br class=""> a~Foo~b<br class=""></blockquote><br class="">Ok, then yes, introducing a magic syntax would be technically feasible (though not backticks, since they are used for something else).<br class=""><br class="">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 class=""><br class="">-Chris<br class=""><br class=""></div></div></blockquote></div><br class=""></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""></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" 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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>