<div dir="ltr">Why not define some other symbol so that you can get the precedence you want?</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"> -- Howard.<br></div></div>
<br><div class="gmail_quote">On 30 November 2016 at 09:28, Greg Parker via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Nov 29, 2016, at 2:55 AM, Rick Mann via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
><br>
> Working on dimensional analysis, I have some proof-of-concept code that seems to be working:<br>
><br>
> let n1 = kilogram * meter / second * second<br>
> ([(kg⋅m) / s]⋅s)<br>
><br>
> let n2 = kilogram * meter / (second * second)<br>
> [(kg⋅m) / (s⋅s)]<br>
><br>
> Note: () around unit products, [] around unit quotients.<br>
><br>
> I'd like to adjust the precedence of operator * for my Unit protocol to be higher than /. Is that possible? It wasn't at all clear to me how to do that in Swift 3, or if can even be done at all.<br>
<br>
You can't. A Swift operator's precedence is the same for all types that implement that operator. Operators * and / cannot use the same precedence on Int but different precedence on Unit.<br>
<br>
You could try to change the precedence of * and / globally - they're defined like any other operator in stdlib/public/core/Policy.<wbr>swift - but you'll break lots of other code that way.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Greg Parker <a href="mailto:gparker@apple.com">gparker@apple.com</a> Runtime Wrangler<br>
<br>
<br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
</font></span></blockquote></div><br></div>