[swift-evolution] [Proposal] Custom operators
Антон Жилин
antonyzhilin at gmail.com
Sat Apr 9 12:43:40 CDT 2016
As always, link to the proposal:
https://github.com/Anton3/swift-evolution/blob/operator-precedence/proposals/NNNN-operator-precedence.md
Without further ado, I changed syntax for declaring that an operator
belongs to a group. It now looks like:
infix operator <> : Comparative
Next, I added a notion of default precedence group for infix operators:
https://github.com/Anton3/swift-evolution/blob/operator-precedence/proposals/NNNN-operator-precedence.md#default-precedence-group
Next, I added a notion of special operatrors that will allow nice
declarations in the Standard Library:
https://github.com/Anton3/swift-evolution/blob/operator-precedence/proposals/NNNN-operator-precedence.md#special-operators
I have a question on this: is that right? Because corresponding operator
functions still won't be declared anywhere.
Now, I see only 1 large question/problem risen by David Waite:
Should precedence relationships be defined inside or outside of precedence
groups?
That is: should we be able to add arbitrary relationships between existing
groups?
If we discuss this and no more problems are discovered, then I think, we
will be ready for review.
2016-04-09 16:40 GMT+03:00 Chris Lattner <clattner at apple.com>:
> > On Apr 9, 2016, at 6:36 AM, Chris Lattner via swift-evolution <
> swift-evolution at swift.org> wrote:
> > I do think it is useful to be able to specify precedence relationships
> without having to define a “group”, to avoid boilerplate when you have one
> operator at a logical level (“??” for example).
>
> Thought there is the obvious counterpoint: sugaring this one case doesn’t
> seem worthwhile, given how infrequently operators are defined. It is quite
> reasonable to start simple and always require an operator to be a member of
> a group. We could eliminate that boilerplate at some point down the road
> if it is an issue in practice.
>
> -Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160409/ab938ad5/attachment.html>
More information about the swift-evolution
mailing list