[swift-evolution] [Proposal] Custom operators

Антон Жилин antonyzhilin at gmail.com
Mon Apr 18 05:09:08 CDT 2016

Sorry for the delay, please mail me a copy next time :)


Антон Жилин:
> > No new suggestions have come in 2 days, and so I have created a pull
> request!
> > https://github.com/apple/swift-evolution/pull/253
> 1. Assignment operators in Swift 2.2 have an `assignment` keyword:
> infix operator += {
>   associativity right
>   precedence 90
>   assignment
> }

Right, it was planned to be removed anyway, and so I did not include it in
the new syntax on purpose. Added removal of `assignment` to "details".

2. If assignments can't be chained, should they be non-associative?

Agreed, these operators are actually non-associative right now. Fixed that,

> 3. Instead of `precedencegroup`, I suggest an abstract declaration:
> operator Multiplicative {
>   associativity(left)
>   precedence(> Additive)
> }
> infix operator * : Multiplicative

Basically, change `precedencegroup` to `operator`?
In terms of keywords, operator will be only a local keyword in my proposal,
so I can say that each variant reserves one keyword.

In terms of name itself, I think, `precedencegroup` is more to the point.
Precedence groups are already mentioned in the standard.
On the other hand, I agree that we should not introduce new entities when
Overall, I'm inclined to leave currently proposed syntax.

> 4. In your proposal, `NilCoalesting` should be `NilCoalescing`.
> -- Ben


- Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160418/fb8eb2ca/attachment.html>

More information about the swift-evolution mailing list