Hi all,
I can’t make up my mind. Let me propose two different alternatives that I’m not sure if they have been considered:
ALTERNATIVE 1
Non-mutable (noun-based)
- func union(other: Self) -> Self
+ func union(other: Self) -> Self Assumes union is a noun, i.e. not a verb
- func intersect(other: Self) -> Self
+ func intersection(other: Self) -> Self
- func subtract(other: Self) -> Self
+ func subtraction(other: Self) -> Self
- func exclusiveOr(other: Self) -> Self
+ func symmetricSubtraction(other: Self) -> Self
Mutable (verb-based)
- mutating func unionInPlace(other: Self)
+ mutating func unite(other: Self)
- mutating func intersectInPlace(other: Self)
+ mutating func intersect(other: Self)
- mutating func subtractInPlace(other: Self)
+ mutating func subtract(other: Self)
- mutating func exclusiveOrInPlace(other: Self)
+ mutating func symmetricSubtract(other: Self)
Comments:
With this alternative we keep the union name which I assume is popular. However, one has to accept unite as a verb (for the mutable version) as I wanted all the mutable methods use verbs for consistency. I think unite is acceptable because it can be found in the dictionary and it is a verb.
Notice that all the non-mutable methods use nouns: union, intersection, subtraction and symmetricSubtraction.
I understand some may oppose to symmetricSubtraction saying that symmetricSubraction is not as common as "exclusive or". However, using symmetricSubtraction is consistent with subtraction and it hints to a variation of the “subtraction" operation. We will get used to it quickly / easily.
The mutable methods all use verbs: unite, intersect, subtract and symmetricSubtract.
ALTERNATIVE 2
Non-mutable
- func union(other: Self) -> Self
+ func adding(other: Self) -> Self
- func intersect(other: Self) -> Self
+ func intersecting(other: Self) -> Self
- func exclusiveOr(other: Self) -> Self
+ func exclusiveOring(other: Self) -> Self
- func subtract(other: Self) -> Self
+ func removing(other: Self) -> Self
Mutable
- mutating func unionInPlace(other: Self)
+ mutating func add(other: Self)
- mutating func intersectInPlace(other: Self)
+ mutating func intersect(other: Self)
- mutating func exclusiveOrInPlace(other: Self)
+ mutating func exclusiveOr(other: Self)
- mutating func subtractInPlace(other: Self)
+ mutating func remove(other: Self)
Comments: This alternative gives up on union in favor or add. Many may not like this, that is why I have it as the second alternative. It brings back exclusiveOr and treats it as a verb. Some may argue that exclusiveOr is a noun for the "exclusive or" operation.
···
On Feb 11, 2016, at 11:52 AM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:
Hi All,
The API guidelines working group took up the issue of the InPlace suffix
yesterday, and decided that it was not to be used anywhere in the
standard library. We are planning to apply the changes shown here
<https://gist.github.com/dabrahams/d872556291a3cb797bd5> to the API of
SetAlgebra (and consequently Set) to make it conform to the guidelines
under development.
Comments welcome as usual,
--
-Dave
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution