[swift-evolution] ed/ing, InPlace, Set/SetAlgebra naming resolution
erica at ericasadun.com
Thu Feb 11 13:09:40 CST 2016
My expectations is that the standard operators act upon a set, changing the set.
set1.union(with: set2) tells set1 to perform the union.
set1.unioned(with: set2) creates a new instance where set1 has been unioned with set 2.
Naming: intersected, unioned, and exclusiveOred over intersecting, unioning, exclusiveOring.
Mutating: union, intersection, exclusiveOr.
Non-Mutating, returning new value: unioned(with), intersected(with), exclusiveOred(with)
* I think the -ing endings sound unnatural, stilted, and unmathematical. They make me wince.
* I think you have the nature of the words mis-assigned. In my opinion in this rare case, union, intersection, and exclusiveOr act as verbs as they are mathematical set operations. For example, "what is the result of A union B?" is a reasonable thing to say to a math person or put on an exam question, etc.
Importantly, they produce significant side effects, and should be treated as verbs that operate upon the receiver, updating the receiver, establishing their use for mutating ops.
>>> - use nouns for methods with no side effects (or only incidental ones, like logging)
>>> - use verbs for methods with significant side-effects
> On Feb 11, 2016, at 9:52 AM, Dave Abrahams via swift-evolution <swift-evolution at 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,
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution