[swift-evolution] SetAlgebra naming update
Dave Abrahams
dabrahams at apple.com
Thu Mar 24 19:58:41 CDT 2016
on Thu Mar 24 2016, Erica Sadun <erica-AT-ericasadun.com> wrote:
>> On Mar 24, 2016, at 6:19 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>
>>
>> on Thu Mar 24 2016, Erica Sadun <swift-evolution at swift.org> wrote:
>>
>
>>>>
>>>> On Mar 24, 2016, at 2:39 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>>>
>>>>
>>>> Just an update:
>>>
>>>>
>>>> The naming guidelines working group went back into negotiation over
>>>> the shape of SetAlgebra (and thus, Set and OptionSet) for
>>>> Swift 3, and reached a new consensus. We intend to bring forward a
>>>> proposal for the API shown here:
>>>>
>>>> http://dabrahams.github.io/swift-naming/SetAlgebra-Math.html
>>>>
>>>> and to update the guidelines to suggest using the "form" prefix to
>>>> create a verb phrase for a mutating method when the operation is
>>>> fundamentally non-mutating and described by a noun.
>>>
>>> I've got to say, I expected to hate this until I clicked the link and saw the actual
>>> proposed syntax. For the most part, it's good: clear and readable.
>>>
>>> Not a fan of "subtracting" (would prefer "bySubtracting"). Other than that
>>> really impressed by how this evolved.
>>
>> x by subtracting y
>>
>> means, “give me x, and get it by subtracting y.” The use of “byXXXing”
>> in existing Cocoa APIs doesn't really set a precedent because it was
>> always preceded by a noun that described the result being returned,
>> e.g. “x.stringByAppending(y),” which is a completely different thing.
>>
>
> So far in each of the naming situations where I have disliked a particular form
> ("subtracting" here), the final results have been good. Apparently
> the strategy of pointing out the bad points and letting magic happen behind
> the scenes is a successful one.
>
> Because that's not very helpful:
>
> * excluding
> * differenceFrom
> * minus
> * excepting
> * subtractingElementsFrom / subtractingElements(from: or of:
Don't forget, you need to come up with a pair of mutating/nonmutating
names.
--
Dave
More information about the swift-evolution
mailing list