<div dir="ltr"><div>Hmm, a thought going in a slightly different direction: if these static functions were called like any other function, there might not be a need for having special rules for parameter labels, which can then be freed to denote prefix and postfix operators. In other words, we could have:</div><div><br></div><div>* for infix operators, no labels, like so: `static func + (_ lhs: T, _ rhs: T)`, used like this: `T.+(1, 2)`</div><div>* for prefix and postfix operators, a label, like so: `static func + (prefixing value: T)`, used like this: `T.+(prefixing: 1)`</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 2, 2016 at 6:26 PM, David Sweeris via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><br><blockquote type="cite">On May 2, 2016, at 5:58 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br>On May 2, 2016, at 1:56 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><blockquote type="cite"><blockquote type="cite">  How does one distinguish between calls to a static prefix operator and a<br>  static postfix operator with the same name?<br><br>Ah, that&#39;s a tricky one that I don&#39;t have an immediate answer to, so I&#39;m<br>definitely open to creative thoughts here.<br></blockquote><br>One possibility: just use “qualified operator” notation.<br><br>  lhs T.+= rhs<br><br>  T.++x<br>  x T.++<br></blockquote><br>I’m not sure if this is exactly right, but it seems close.  I think that something like this is probably the best way to go, since it composes properly in arbitrary expressions.  It does have a surface level weirdness to it, but it also &quot;makes sense” in terms of how operators work.  <br></blockquote></span>Yeah… Maybe with parens?<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>T.++(x)</div><div>(x)T.++</div></blockquote><div>Or is that worse?</div><div><br></div><div>- Dave Sweeris</div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div></div>