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

Dave Abrahams dabrahams at apple.com
Fri Feb 12 16:21:46 CST 2016


on Fri Feb 12 2016, Craig Cruden <swift-evolution at swift.org> wrote:

> Not to mention - mutating (in my limited and aged math knowledge) is
> NOT mathematical (computer simulations might use math in simulations
> which simulating something that mutates)
>
> Mathematicians (typically) don’t mutate - they might be mutants….  but
> they don’t mutate their equations.
>
> When was the last time you saw a mutating equation?  If equations
> mutate then it makes it much more difficult to prove correctness.
>
> Probably why even OO programming languages don’t allow you to mutate
> an Integer or Decimal ….. bad things can happen.
>
> Union and intersection have more in common with operations like + and
> - which also do not mutate the values.

Let's not go too far with this.  Euclid invented the GCD algorithm,
which was originally expressed iteratively and therefore can be seen to
be mutating variables.  The whole concept of “algorithm” was named after
an arabic mathematician.

>
> :p
>
>>> Reasoning:
>>> 
>>> * 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.
>
>> 
>
>> On 2016-02-12, at 22:20:01, Thorsten Seitz via swift-evolution
>> <swift-evolution at swift.org> wrote:
>> 
>> I beg to disagree with your reasoning.
>> I think "union" is more commonly used as a noun and "intersection"
>> certainly is not a verb. Your example sounded weird for me (but
>> maybe that's because I'm not a native speaker) and I would rather
>> expect the question to be "What is the union of A and B?"
>> 
>> -Thorsten 
>> 
>> Am 11.02.2016 um 20:09 schrieb Erica Sadun via swift-evolution
>> <swift-evolution at swift.org
>> <mailto:swift-evolution at swift.org>>:
>> 
>>> 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)
>>> 
>>> Reasoning:
>>> 
>>> * 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.
>>> 
>>> Dave wrote:
>>>>>> - use nouns for methods with no side effects (or only incidental ones,  like logging)
>>>>>> - use verbs for methods with significant side-effects
>>> 
>>> 
>>> -- E
>>> 
>>>> On Feb 11, 2016, at 9:52 AM, Dave Abrahams via swift-evolution
>>>> <swift-evolution at swift.org
>>>> <mailto: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
>>>> <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 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>
>>> 
>>> _______________________________________________
>>> 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>
>> _______________________________________________
>> 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



More information about the swift-evolution mailing list