[swift-evolution] [Proposal] Improving operator requirements in protocols

Dave Abrahams dabrahams at apple.com
Tue May 3 12:42:20 CDT 2016


on Mon May 02 2016, David Sweeris <davesweeris-AT-mac.com> wrote:

>     On May 2, 2016, at 5:58 PM, Chris Lattner via swift-evolution
>     <swift-evolution at swift.org> wrote:
>
>     On May 2, 2016, at 1:56 PM, Dave Abrahams via swift-evolution
>     <swift-evolution at swift.org> wrote:
>
>             How does one distinguish between calls to a static prefix operator
>             and a
>             static postfix operator with the same name?
>
>             Ah, that's a tricky one that I don't have an immediate answer to, so
>             I'm
>             definitely open to creative thoughts here.
>
>         One possibility: just use “qualified operator” notation.
>
>         lhs T.+= rhs
>
>         T.++x
>         x T.++
>
>     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 "makes sense” in terms of how operators work. 
>
> Yeah… Maybe with parens?
>
>     T.++(x)
>     (x)T.++
>
> Or is that worse?

The parens are legal if the other syntax is legal, but I don't see a reason
to require them.

-- 
Dave


More information about the swift-evolution mailing list