<div dir="ltr">Hi all,<div><br></div><div>My proposal is to add a precedence option for prefix and postfix operators.  It is great that swift allows for associativity and precedence for binary operators but it hasn&#39;t quite gone all the way to make operator overloading fully functional (just an opinion).  To illustrate consider the following code:</div><div><br></div><div><div>import CoreFoundation</div><div><br></div><div>infix operator ** { associativity right precedence 200 }</div><div><br></div><div>func ** (base: Double, power: Double) -&gt; Double {</div><div>    return pow(base, power)</div><div>}</div><div><br></div><div>print(-3**2)</div><div>print(0-3**2)</div></div><div><br></div><div>which prints 9 and -9.  In the first case because unary minus has higher precedence as a prefix operator it evaluates to (-3)*(-3) and the second because - is viewed as a binary operator of lower precedence as (0-(3*3).  Exponentiation has higher precedence than subtraction so -3**2 should be -9 and the two expressions above are mathematically equivalent.  I originally reported this as a bug (SR-552) as to me the point of operator overloading is to allow you to write numerical expressions cleanly but should give you the correct mathematical result.  The only really useful application I can think of for operator overloading is basically as a DSL for numerical expressions.  If it doesn&#39;t allow you to get correct results without having to put brackets everywhere it sort of defeats the purpose (just my opinion of course).</div><div><br></div><div>Best regards,</div><div>Jason</div></div>