<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="">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 "discovered", and that's why the identifier character sets and operator character sets have no overlap right now.<div class=""><br class=""></div><div class="">"as" and "is" are not operators, they're keywords that were hard-coded into the grammar.<br class=""><div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class="">Félix</span>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Le 7 janv. 2016 à 04:31:10, Jo Albright via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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 class=""><br class=""></div><div class="">Here are my reasons for allowing them:</div><div class=""><br class=""></div><div class="">1. easier to read “within” vs “><span style="font-family: Menlo; font-size: 11px;" class="">*</span><“ or “|<span style="font-family: Menlo; font-size: 11px;" class="">*</span>|” </div><div class=""><br class=""></div><div class="">2. potential opportunity to build an educational library to help explain expressions (see below)</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="">infix<span style="" class=""> </span>operator<span style="" class=""> plus { </span>associativity<span style="" class=""> left </span>precedence<span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">200</span><span style="" class=""> }</span></div></div><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; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">public </span><font color="#bb2ca2" face="Menlo" class=""><span style="font-size: 11px;" class="">func</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class=""> plus </span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">(lhs: </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">, rhs: </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">) -> <font color="#703daa" class="">Int</font></span></font><font face="Menlo" class=""><span style="font-size: 11px;" class=""> {</span></font></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> lhs + rhs</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> totalApples = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span> <font color="#31595d" class="">plus</font> <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">5</span></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">postfix</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">operator</span><span style="font-family: Menlo; font-size: 11px;" class=""> oz {</span><span style="font-family: Menlo; font-size: 11px;" class=""> }</span></div><div class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">postfix<span style="" class=""> </span>operator<span style="" class=""> cup {</span><span style="" class=""> }</span></div></div><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">postfix</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">operator</span><span style="font-family: Menlo; font-size: 11px;" class=""> gal {</span><span style="font-family: Menlo; font-size: 11px;" class=""> }</span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">public </span><font face="Menlo" class=""><font color="#bb2ca2" class=""><span style="font-size: 11px;" class="">func</span></font><span style="font-size: 11px;" class=""> oz </span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">(</span></font><span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace; text-indent: -32px;">inout</span><span style="font-family: Menlo, monospace; text-indent: -32px; background-color: rgb(249, 249, 249);" class=""> </span><span class="nl" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; text-indent: -32px;">_ </span><font face="Menlo" class=""><span style="font-size: 11px;" class="">lhs: </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Double</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">) -> </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Double</span><span style="font-size: 11px; font-family: Menlo;" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></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> lhs</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">public </span><font face="Menlo" class=""><font color="#bb2ca2" class=""><span style="font-size: 11px;" class="">func</span></font><span style="font-size: 11px;" class=""> cup </span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">(</span></font><span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace; text-indent: -32px;">inout</span><span style="font-family: Menlo, monospace; text-indent: -32px; background-color: rgb(249, 249, 249);" class=""> </span><span class="nl" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; text-indent: -32px;">_ </span><font face="Menlo" class=""><span style="font-size: 11px;" class="">lhs: </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Double</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">) -> </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Double</span><span style="font-size: 11px; font-family: Menlo;" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></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> lhs *= 8.0 </div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">public </span><font face="Menlo" class=""><font color="#bb2ca2" class=""><span style="font-size: 11px;" class="">func</span></font><span style="font-size: 11px;" class=""> gal </span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">(</span></font><span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145); font-family: Menlo, monospace; text-indent: -32px;">inout</span><span style="font-family: Menlo, monospace; text-indent: -32px; background-color: rgb(249, 249, 249);" class=""> </span><span class="nl" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; text-indent: -32px;">_ </span><font face="Menlo" class=""><span style="font-size: 11px;" class="">lhs: </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Double</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">) -> </span></font><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Double</span><span style="font-size: 11px; font-family: Menlo;" class=""> {</span></div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">return</span> lhs *= 128.0</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal;" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">let</span> totalLiquidInOunces = <span style="color: rgb(39, 42, 216);" class="">5oz</span><font color="#31595d" class=""> plus</font> <font color="#272ad8" class="">2</font><span style="color: rgb(49, 89, 93);" class="">cup</span><font color="#272ad8" class=""> </font><span style="color: rgb(49, 89, 93);" class="">plus </span><font color="#272ad8" class="">1</font><font color="#31595d" class="">gal</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I spent awhile looking to make sure this hasn’t been proposed before. I apologize if it is a repeat.</div><div class=""><br class=""></div><div class="">Thanks</div><div class="">
<br class="Apple-interchange-newline"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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; float: none; display: inline !important;" class=""><font color="#8d8d8d" class=""><span class="Apple-converted-space"> </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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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; 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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class="">
</div>
<br class="">
<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="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" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>