[swift-evolution] [Proposal] Custom operators

Maximilian Hünenberger m.huenenberger at me.com
Sat Apr 9 18:27:20 CDT 2016


> Am 09.04.2016 um 19:43 schrieb Антон Жилин <antonyzhilin at gmail.com>:
> [...]
> 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?
> [...]

I'm in favor of declaring precedence relationships inside precedencegroup declarations. So they have a fixed place where they are defined.


The only minor syntax issue I have is that it is not immediately clear which operators belong to a precedence group. The former syntax with the "members(+, -)" solved this issue. However this has (currently) an extensibility problem:
If you define a new operator and it should belong to a precedencegroup where you have no access to its source (like Additive) then the whole argument about having operators in one place.


Another minor issue regarding your implementation of the standard library operators: "Additive" and all "Bitwise" precedencegroups should be above "Range"

// so this is also possible without parentheses
(1+2) ... (3+5)

This issue can be brought up again during another proposal which implements this proposal. So the standard library changes should not belong to this proposal (or least be clarified).

Kind regards
- Maximilian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160410/eb94f869/attachment.html>


More information about the swift-evolution mailing list