<p dir="ltr">Jo, it sounds like you&#39;re describing infix functions. If you want to bring up a concrete example, Kotlin has this implementation and it&#39;s fantastic for creating your own syntactic sugar. </p>
<br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 7, 2016, 11:31 AM Félix Cloutier &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">In a discussion about adding $ to the operator character set (it currently is an identifier character), Chris said that any token must be unambiguously either an identifier or an operator even before operators are &quot;discovered&quot;, and that&#39;s why the identifier character sets and operator character sets have no overlap right now.<div><br></div><div>&quot;as&quot; and &quot;is&quot; are not operators, they&#39;re keywords that were hard-coded into the grammar.<br><div>
<br><span style="color:rgb(0,0,0);font-family:&#39;Lucida Grande&#39;;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;display:inline!important;float:none">Félix</span>
</div></div></div><div style="word-wrap:break-word"><div>

<br><div><blockquote type="cite"><div>Le 7 janv. 2016 à 04:31:10, Jo Albright via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br><div><div style="word-wrap:break-word"><div>As my obsession grows with custom operators. I have come across wanting to use small words or 1-2 alphabetical characters as custom operators. I noticed that “as” and “is” are character based operators and figured it wouldn’t hurt to propose the allowance of character based custom operators.</div><div><br></div><div>Here are my reasons for allowing them:</div><div><br></div><div>1. easier to read “within” vs “&gt;<span style="font-family:Menlo;font-size:11px">*</span>&lt;“ or “|<span style="font-family:Menlo;font-size:11px">*</span>|” </div><div><br></div><div>2. potential opportunity to build an educational library to help explain expressions (see below)</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">infix<span> </span>operator<span> plus { </span>associativity<span> left </span>precedence<span> </span><span style="color:#272ad8">200</span><span> }</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span><br></span></div><div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">public </span><font color="#bb2ca2" face="Menlo"><span style="font-size:11px">func</span></font><font face="Menlo"><span style="font-size:11px"> plus </span></font><font face="Menlo"><span style="font-size:11px">(lhs: </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Int</span><font face="Menlo"><span style="font-size:11px">, rhs: </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Int</span><font face="Menlo"><span style="font-size:11px">) -&gt; <font color="#703daa">Int</font></span></font><font face="Menlo"><span style="font-size:11px"> {</span></font></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">return</span> lhs + rhs</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">}</div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">let</span> totalApples = <span style="color:#272ad8">5</span> <font color="#31595d">plus</font> <span style="color:#272ad8">5</span></div><div><br></div><div>3. potential to write more like a sentence (this isn’t as high of a need, but again a good for entry into the language) </div><div><br></div><div><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">postfix</span><span style="font-family:Menlo;font-size:11px"> </span><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">operator</span><span style="font-family:Menlo;font-size:11px"> oz {</span><span style="font-family:Menlo;font-size:11px"> }</span></div><div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)">postfix<span> </span>operator<span> cup {</span><span> }</span></div></div><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">postfix</span><span style="font-family:Menlo;font-size:11px"> </span><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">operator</span><span style="font-family:Menlo;font-size:11px"> gal {</span><span style="font-family:Menlo;font-size:11px"> }</span></div><div><font face="Menlo"><span style="font-size:11px"><br></span></font><div><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">public </span><font face="Menlo"><font color="#bb2ca2"><span style="font-size:11px">func</span></font><span style="font-size:11px"> oz </span></font><font face="Menlo"><span style="font-size:11px">(</span></font><span style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145);font-family:Menlo,monospace">inout</span><span style="font-family:Menlo,monospace;background-color:rgb(249,249,249)"> </span><span style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace">_ </span><font face="Menlo"><span style="font-size:11px">lhs: </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Double</span><font face="Menlo"><span style="font-size:11px">) -&gt; </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Double</span><span style="font-size:11px;font-family:Menlo"> {</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:rgb(187,44,162)">return</span> lhs</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">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">public </span><font face="Menlo"><font color="#bb2ca2"><span style="font-size:11px">func</span></font><span style="font-size:11px"> cup </span></font><font face="Menlo"><span style="font-size:11px">(</span></font><span style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145);font-family:Menlo,monospace">inout</span><span style="font-family:Menlo,monospace;background-color:rgb(249,249,249)"> </span><span style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace">_ </span><font face="Menlo"><span style="font-size:11px">lhs: </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Double</span><font face="Menlo"><span style="font-size:11px">) -&gt; </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Double</span><span style="font-size:11px;font-family:Menlo"> {</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:rgb(187,44,162)">return</span> lhs *= 8.0 </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">}</div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="font-family:Helvetica;font-size:12px;margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">public </span><font face="Menlo"><font color="#bb2ca2"><span style="font-size:11px">func</span></font><span style="font-size:11px"> gal </span></font><font face="Menlo"><span style="font-size:11px">(</span></font><span style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145);font-family:Menlo,monospace">inout</span><span style="font-family:Menlo,monospace;background-color:rgb(249,249,249)"> </span><span style="border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;font-family:Menlo,monospace">_ </span><font face="Menlo"><span style="font-size:11px">lhs: </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Double</span><font face="Menlo"><span style="font-size:11px">) -&gt; </span></font><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Double</span><span style="font-size:11px;font-family:Menlo"> {</span></div><div style="margin:0px;line-height:normal;min-height:13px">    <br></div><div style="margin:0px;line-height:normal">    <span style="color:rgb(187,44,162)">return</span> lhs *= 128.0</div><div style="margin:0px;line-height:normal;min-height:13px">    <br></div><div style="margin:0px;line-height:normal">}</div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> totalLiquidInOunces = <span style="color:rgb(39,42,216)">5oz</span><font color="#31595d"> plus</font> <font color="#272ad8">2</font><span style="color:rgb(49,89,93)">cup</span><font color="#272ad8"> </font><span style="color:rgb(49,89,93)">plus </span><font color="#272ad8">1</font><font color="#31595d">gal</font></div></div><div><br></div><div><br></div><div>I spent awhile looking to make sure this hasn’t been proposed before. I apologize if it is a repeat.</div><div><br></div><div>Thanks</div><div>
<br><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="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="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>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k5E-2BmOUZmxMSx5fbKRSHB9THm-2F9b3u-2F93wx1Le-2BtSJn9lBMUq4lkAZh6Ru3YNm-2BHeXjMluHJWu2dX1ad-2BDmGXEgw9H28sle6Um-2BLhKZWgNFQhfjlesTVkXfcK9-2BeflK3vaKpX4WDRKkOjWHaBjDdcFbwwssbtUd6xBT438FxDSbj5Im8v1K45PG8npXU1-2FRHGo-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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div><div style="word-wrap:break-word"><div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=8CZIdLciSFC-2BO5jF-2FiP8qN7dBFsgCUZ50wdTsolcRPde-2BHWr-2F9v3Eimbl8DPSJpeIh9dR1WrJWL3Oo8-2Bg3p1DmLKeTBJrX60FP421vIvoDcg7rDzwxKIeRJ1lOBa30o4tX-2BcgxmhWUBbzoO7K-2FdraDb0eLxEeyy4MR32Y3KYjD4g0upY0lA-2FGNxOPf9Zyu1FyGBczehQiixuhyStjYV-2FeaqyGmvoKYC0k25H2yyKsYk-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>