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

Craig Cruden ccruden at novafore.com
Tue Feb 16 13:25:08 CST 2016


Richard’s suggestions is amount the better ones:

Of the symdiff ones I think I would lean towards:

let symmetricDifference = 	a.unionMinusIntersection(b)	// (a ∪ b) \ (a ∩ b) == a △ b

It is descriptive enough for those not familiar with the name “symmetricDifference”. 

The fact that he keeps mutable names completely separate is a plus.



> On 2016-02-17, at 2:16:24, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> on Tue Feb 16 2016, Xiaodi Wu <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>> Not that I like it, but
>> insertNonIntersectingRemoveIntersectingContentsOf(_:) would be the
>> stylistically consistent way to convey the right sense.
> 
> Did you see Ricardo Parada's suggestions?  I thought some of those were
> better.
> 
>> On Tue, Feb 16, 2016 at 10:22 AM Dave Abrahams via swift-evolution <
>> swift-evolution at swift.org> wrote:
>> 
>>> 
>>> 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
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> -- 
> -Dave
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160217/bd5fee87/attachment.html>


More information about the swift-evolution mailing list