<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 8 Feb 2016, at 22:02, Jessy Catterwaul via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; min-height: 16px;" class="">While I believe that instance operators would represent the vast majority of operations, operators that use operands of different types don’t make sense to be defined in a type. I love that Swift allows that sort of thing at module scope.</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> * (matrix: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Matrix2x2</span><span style="font-variant-ligatures: no-common-ligatures" class="">, vector: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Vector2</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Vector2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {…</span></div></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">I bet it makes sense to enforce that an operator is only allowed at module scope if its operands aren’t of the same type.</span></div></div></div></blockquote></div><br class=""><div class="">Would it even need to be that complex? I would say to just allow global scope operators as well, and leave it to the developer to decide if that’s the best place to put it versus putting it into a type.</div><div class=""><br class=""></div><div class="">That said, I’m finding it hard to think of examples that really need to be in the global scope, as your example seems to me like it still makes the most sense to be placed within the Matrix2x2 type like so:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func * (vector:Vector2) -> Vector2 { // self is matrix2x2 }</font></div><div class=""><br class=""></div><div class="">Since the left hand side is still the focal point of this operator. The only case I could think of that might still require a global operator would be one that can handle arguments of type Any.</div></body></html>