Maybe one minimalist approach could be to have these take two arguments as though it's an infix operator where one of lhs or rhs is Void:<br><br>T.++(&value, ()) //postfix<br>T.++((), &value) // prefix<br><div class="gmail_quote"><div dir="ltr">On Mon, May 2, 2016 at 15:56 Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
on Mon May 02 2016, Tony Allevato <allevato-AT-google.com> wrote:<br>
<br>
> On Mon, May 2, 2016 at 1:20 PM Dave Abrahams via swift-evolution<br>
> <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> Tony, thanks for writing this up!<br>
><br>
> on Mon May 02 2016, Tony Allevato <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> > Other kinds of operators (prefix, postfix, assignment)<br>
> ><br>
> > Static operator methods have the same signatures as their global<br>
> counterparts.<br>
> > So, for example, prefix and postfix operators as well as assignment<br>
> operators<br>
> > would be defined the way one would expect:<br>
> ><br>
> > protocol SomeProtocol {<br>
> > static func +=(lhs: inout Self, rhs: Self)<br>
> > static prefix func ~(value: Self) -> Self<br>
> ><br>
> > // This one is deprecated, of course, but used here just to serve as an<br>
> > // example.<br>
> > static postfix func ++(value: inout Self) -> Self<br>
> > }<br>
> ><br>
> > // Trampolines<br>
> > func += <T: SomeProtocol>(lhs: inout T, rhs T) {<br>
> > T.+=(&lhs, rhs)<br>
> > }<br>
> > prefix func ~ <T: SomeProtocol>(value: T) -> T {<br>
> > return T.~(value)<br>
> > }<br>
> > postfix func ++ <T: SomeProtocol>(value: inout T) -> T {<br>
> > return T.++(&value)<br>
> > }<br>
><br>
> 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's a tricky one that I don't have an immediate answer to, so I'm<br>
> definitely open to creative thoughts here.<br>
<br>
One possibility: just use “qualified operator” notation.<br>
<br>
lhs T.+= rhs<br>
<br>
T.++x<br>
x T.++<br>
<br>
> The first stab I would take at is, what if we included the token "prefix" or<br>
> "suffix" before the operator name in the expression, like this?<br>
><br>
> return T.prefix ++(&value)<br>
> return T.postfix ++(&value)<br>
><br>
> But that could start to look like an invocation of "++" on a static property<br>
> "T.prefix". I haven't dug into the parser to determine if that would even be<br>
> feasible or not.<br>
<br>
These are not unreasonable either:<br>
<br>
return prefix T.++(&value)<br>
return postfix T.++(&value)<br>
<br>
--<br>
Dave<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">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>
</blockquote></div>