[swift-evolution] ed/ing, InPlace, Set/SetAlgebra naming resolution

Dave Abrahams dabrahams at apple.com
Tue Feb 16 10:20:56 CST 2016


on Mon Feb 15 2016, Brent Royal-Gordon <swift-evolution at swift.org> wrote:

> I think you've ended up with the right approach, and I understand the need to move on, but...
>
>>     /// Returns the set of elements contained in `self` or in `other`, but not in both `self` and `other`.
>>     /// EXISTING: exclusiveOr
>>     @warn_unused_result
>>     func invertingIntersection(other: Self) -> Self
>>     
>>     /// Replaces `self` with a set containing all elements contained in either `self` or `other`, but not both.
>>     /// EXISTING: exclusiveOrInPlace
>>     mutating func invertIntersection(other: Self)
>
> I'm not quite happy with these. I don't like that the mutating form of
> `intersection` is `intersect`, but the mutating form of
> `invertingIntersection` is `invertIntersection`—it seems like both
> methods should change the "intersection" part.
>
> Have you considered going the opposite direction and combining the verb "intersect" with the adjective "inverse"?
>
>     /// Returns the set of elements contained in `self` or in `other`, but not in both `self` and `other`.
>     /// EXISTING: exclusiveOr
>     @warn_unused_result
>     func inverseIntersection(other: Self) -> Self
>
>     /// Replaces `self` with a set containing all elements contained in either `self` or `other`, but not both.
>     /// EXISTING: exclusiveOrInPlace
>     mutating func inverseIntersect(other: Self)
>     // or perhaps even `inverselyIntersect` so it's an adverb
>
> I wouldn't be surprised if you did, because I could see you trying to
> dodge the adverb problem, but I thought it was worth asking.

These names all have the wrong sense, including the ones that were
decided upon.  “Inverting the intersection” doesn't imply that elements
not in the intersection will be merged, which is what happens in a
symmetric difference.

-- 
-Dave



More information about the swift-evolution mailing list