[swift-evolution] [Returned for revision] SE-0077: Improved operator declarations

Dave Abrahams dabrahams at apple.com
Tue Jun 28 13:02:06 CDT 2016


on Thu Jun 23 2016, Xiaodi Wu <swift-evolution at swift.org> wrote:

> On Wed, Jun 22, 2016 at 10:24 PM, Joe Groff via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> Proposal link:
>> https://github.com/apple/swift-evolution/blob/master/proposals/0077-operator-precedence.md
>>
>> Hello Swift Community,
>>
>> The review of SE-0077: "Improved operator declarations" ran from May
>> 17...23. On June 22, 2016, the core team decided to *return* the first
>> version of this proposal for revision. The core design proposed is a clear
>> win over the Swift 2 design, but the core team feels that revisions are
>> necessary for usability and consistency with the rest of the language:
>>
>> - The proposed associativity(left) and precedence(<) syntax for
>> precedence group attributes doesn’t have a precedent elsewhere in Swift.
>> Furthermore, it isn’t clear which relationship < and > correspond to in
>> the precedence syntax. The core team feels that it’s more in the character
>> of Swift to use colon-separated “key-value” syntax, with associativity,
>> strongerThan, and weakerThan keyword labels:
>>
>>
>> precedencegroup Foo {
>>
>>   associativity: left
>>
>>   strongerThan: Bar
>>
>>   weakerThan: Bas
>>
>> }
>>
>>
>> -If “stronger” and “weaker” relationships are both allowed, that would
>> enable different code to express precedence relationships in different,
>> potentially confusing ways. To promote consistency and clarity, the core
>> team recommends the following restriction: Relationships between precedence
>> groups defined within the same module must be expressed exclusively in
>> terms of strongerThan. weakerThan can only be used to extend
>> the precedence graph relative to another module’s groups, subject to the
>> transitivity constraints already described in the proposal. This enforces a
>> consistent style internally within modules defining operators.
>>
>>
> This definitely looks cleaner, but the terminology "stronger" and "weaker"
> is pretty non-standard. Typically, precedence is said to be above or below
> (equivalently, over or under, higher or lower) or, alternatively, before or
> after. 

Although I was the one who suggested “stronger/weaker”, on reflection I
think “higher/lower” are the most standard terms here.

-- 
Dave



More information about the swift-evolution mailing list