<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 14, 2016, at 8:27 AM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">on Sat Feb 13 2016, Tyler Fleming Cloutier &lt;<a href="http://cloutiertyler-at-aol.com" class="">cloutiertyler-AT-aol.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">I would, personally, be very careful about discarding the mathematical<br class="">terms since they are so widely used and understood.<br class=""></blockquote><br class="">IMO it's better to leave them aside than to use them in “creative” ways<br class="">that might be misleading.<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>Agreed. I’m all for that.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><blockquote type="cite" class="">One issue is that it’s going to be hard to search for the operation I<br class="">want considering I won’t be looking for "func<br class="">invertingMembershipOfContentsOf(other: Self) -&gt; Self”. I’m concerned<br class="">people are going to have to do mental gymnastics to build the map from<br class="">math term to Swift function every time they want to look for a set<br class="">operation method. “func invertingMembershipOfContentsOf(other: Self)<br class="">-&gt; Self” doesn’t exactly seem to fit in the commonly held Venn diagram<br class="">mental model of set operations. You could always have a documentation<br class="">comment that specifies the mathematical term so that people didn’t<br class="">have to double check themselves every time.<br class=""><br class="">That being said, if the autocomplete issue is not a concern, I’m of<br class="">the opinion that the names Ricardo proposed are short, clear, and are<br class="">not so hard to fit to my Venn diagram mental model.<br class=""></blockquote><br class="">+1<br class=""><br class=""><blockquote type="cite" class="">However, I tend to think that if there has to be this much dancing to<br class="">name a set of fundamental operations, the guidelines aren’t<br class="">accomplishing their goal. <br class=""></blockquote><br class="">I can't disagree.<br class=""><br class=""><blockquote type="cite" class="">It’s going to make it that much harder for people do design their own<br class="">APIs. I'm having quite a time trying to conform Mattt’s Surge API to<br class="">the guidelines.<br class=""></blockquote><br class="">Please explain in detail. &nbsp;Without details we don't know what's wrong<br class="">with the guidelines.<br class=""></div></div></blockquote><div><br class=""></div><div>Ah, I apologize. I’ve gone into detail about this API on the list before, but I should have included the details here.</div><div><br class=""></div><div>Here are my previous posts:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007560.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007560.html</a></div><div><br class=""></div><div>Basically the issues come down to the following. The Accelerate framework typical operates in a non-mutating way. This means that my API only has non mutating member functions and I should use the ed/ing rule according to the guidelines to name my methods.</div><div><br class=""></div><div>This is very difficult for some methods. I’m able to frequently get around the problem for things like “sin” or “arctan” by keeping them as global functions, but I can’t do that for a number of methods. Consider:</div><div><br class=""></div><div>remainder</div><div>dot (returns a scalar, thus there can’t be a mutating version, so should I just call it dot? Guidelines don’t really comment on this)</div><div>mean (same as above)</div><div>cross</div><div>reciprocal</div><div>threshold</div><div>copysign</div><div>fastFourierTransform</div><div>pow (arguably the method version should be called raisedTo)</div><div><br class=""></div><div>I could force all these to be global functions only, but these are not as cut and dry as “sin” or “arctan”. I feel like I’d be splitting my API up into two parts just based on the fact that it’s difficult to use the ed/ing rule. That makes it very difficult for users to find certain functions in my API.</div><div><br class=""></div><div>In this case there are no corresponding mutating operations because of the way Accelerate works, but one could certainly imagine an API with mutating counterparts. The way I read the guidelines, they seem to imply I should use ed/ing regardless of whether there is a mutating counterpart. I’d love to hear your thoughts on this.</div><div><br class=""></div><div>Thanks,</div><div><br class=""></div><div>Tyler</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><br class="">Tyler<br class=""><br class=""><blockquote type="cite" class="">On Feb 13, 2016, at 9:09 PM, Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Hi Dave,<br class=""><br class="">I would be okay with staying away from the mathematical terms<br class="">similar to what you are suggesting except that the union can still<br class="">be made more concise if you use merged / merge for the base name and<br class="">shorten the labels to a bare minimum without loosing clarity. &nbsp;In<br class="">addition, the merge can have a second parameter with a default to<br class="">false in order to implement the symmetric difference<br class="">(a.k.a. exclusive or). &nbsp;Recall that symmetric difference is the<br class="">union of two sets and then removing the intersection (or members in<br class="">common). &nbsp;I think it looks perfect (concise and clear). &nbsp;What does<br class="">everybody else think?<br class=""><br class="">Non-mutable<br class=""><br class="">let union = <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>a.merged(with: b)<br class="">let intersection = <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>a.members(in: b)<br class="">let difference = <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>a.removingMembers(in: b)<br class="">let symmetricDifference = <span class="Apple-tab-span" style="white-space:pre">        </span>a.merged(with: b, removingMembersInCommon: true)<br class=""><br class="">Mutable (In-Place)<br class=""><br class="">a.merge(with: b)<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// union in-place<br class="">a.removeMembers(notIn: b)<span class="Apple-tab-span" style="white-space:pre">        </span>// intersect in-place<br class="">a.removeMembers(in: b)<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// difference in-place<br class="">a.merge(with: b, removeMembersInCommon: true)<span class="Apple-tab-span" style="white-space:pre">        </span>// symmetric difference in-place<br class=""><br class="">Ricardo Parada<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Feb 13, 2016, at 1:16 PM, Dave Abrahams via swift-evolution<br class="">&lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt;<br class="">wrote:<br class=""><br class=""><br class="">on Fri Feb 12 2016, Ricardo Parada &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">&lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">Hi all,<br class=""><br class="">I can’t make up my mind. &nbsp;Let me propose two different alternatives<br class="">that I’m not sure if they have been considered:<br class=""><br class="">ALTERNATIVE 1<br class=""><br class="">Non-mutable (noun-based)<br class=""><br class="">- &nbsp;func union(other: Self) -&gt; Self<br class="">+ &nbsp;func union(other: Self) -&gt; Self<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>Assumes union is a noun, i.e. not a verb<br class=""><br class="">- &nbsp;func intersect(other: Self) -&gt; Self<br class="">+ &nbsp;func intersection(other: Self) -&gt; Self<br class=""><br class="">- &nbsp;func subtract(other: Self) -&gt; Self<br class="">+ &nbsp;func subtraction(other: Self) -&gt; Self<br class=""><br class="">- &nbsp;func exclusiveOr(other: Self) -&gt; Self<br class="">+ &nbsp;func symmetricSubtraction(other: Self) -&gt; Self<br class=""><br class="">Mutable (verb-based)<br class=""><br class="">- &nbsp;mutating func unionInPlace(other: Self)<br class="">+ &nbsp;mutating func unite(other: Self)<br class=""><br class="">- &nbsp;mutating func intersectInPlace(other: Self)<br class="">+ &nbsp;mutating func intersect(other: Self)<br class=""><br class="">- &nbsp;mutating func subtractInPlace(other: Self)<br class="">+ &nbsp;mutating func subtract(other: Self)<br class=""><br class="">- &nbsp;mutating func exclusiveOrInPlace(other: Self)<br class="">+ &nbsp;mutating func symmetricSubtract(other: Self)<br class=""><br class="">Comments: <br class=""><br class="">With this alternative we keep the union name which I assume is<br class="">popular. &nbsp;However, one has to accept unite as a verb (for the mutable<br class="">version) as I wanted all the mutable methods use verbs for<br class="">consistency. &nbsp;I think unite is acceptable because it can be found in<br class="">the dictionary and it is a verb.<br class=""><br class="">Notice that all the non-mutable methods use nouns: union,<br class="">intersection, subtraction and symmetricSubtraction.<br class=""><br class="">I understand some may oppose to symmetricSubtraction saying that<br class="">symmetricSubraction is not as common as "exclusive or". &nbsp;However,<br class="">using symmetricSubtraction is consistent with subtraction and it hints<br class="">to a variation of the “subtraction" operation. &nbsp;We will get used to it<br class="">quickly / easily.<br class=""><br class="">The mutable methods all use verbs: &nbsp;unite, intersect, subtract and symmetricSubtract.<br class=""><br class="">ALTERNATIVE 2<br class=""><br class="">Non-mutable<br class=""><br class="">- &nbsp;func union(other: Self) -&gt; Self<br class="">+ &nbsp;func adding(other: Self) -&gt; Self<br class=""><br class="">- &nbsp;func intersect(other: Self) -&gt; Self<br class="">+ &nbsp;func intersecting(other: Self) -&gt; Self<br class=""><br class="">- &nbsp;func exclusiveOr(other: Self) -&gt; Self<br class="">+ &nbsp;func exclusiveOring(other: Self) -&gt; Self<br class=""><br class="">- &nbsp;func subtract(other: Self) -&gt; Self<br class="">+ &nbsp;func removing(other: Self) -&gt; Self<br class=""><br class="">Mutable<br class=""><br class="">- &nbsp;mutating func unionInPlace(other: Self)<br class="">+ &nbsp;mutating func add(other: Self)<br class=""><br class="">- &nbsp;mutating func intersectInPlace(other: Self)<br class="">+ &nbsp;mutating func intersect(other: Self)<br class=""><br class="">- &nbsp;mutating func exclusiveOrInPlace(other: Self)<br class="">+ &nbsp;mutating func exclusiveOr(other: Self)<br class=""><br class="">- &nbsp;mutating func subtractInPlace(other: Self)<br class="">+ &nbsp;mutating func remove(other: Self)<br class=""><br class="">Comments: This alternative gives up on union in favor or add. &nbsp;Many<br class="">may not like this, that is why I have it as the second alternative.<br class="">It brings back exclusiveOr and treats it as a verb. &nbsp;Some may argue<br class="">that exclusiveOr is a noun for the "exclusive or" operation.<br class=""></blockquote><br class="">If we are going to force Set fit the naming guidelines, I would prefer<br class="">to stay away from the mathematical terms altogether.<br class=""><br class=""> &nbsp;func insertingContentsOf(other: Self) -&gt; Self &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// union<br class=""> &nbsp;mutating func insertContentsOf(other)<br class=""><br class=""> &nbsp;func members(in other: Self) -&gt; Self &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// intersection<br class=""> &nbsp;mutating func removeMembers(notIn: other)<br class=""><br class=""> &nbsp;func removingMembersAndAddingNonMembers(in other: Self) -&gt; Self // symmetric difference<br class=""> &nbsp;mutating func removeMembersAndAddingNonMembers(in other: Self)<br class=""><br class=""> &nbsp;func removingMembers(in other: Self) -&gt; Self &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// subtract<br class=""> &nbsp;mutating func removeMembers(in other: Self)<br class=""><br class="">If it would help with clarity, we could replace "in" with "foundIn"<br class="">above.<br class=""><br class="">-- <br class="">-Dave<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;<br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">&lt;https://lists.swift.org/mailman/listinfo/swift-evolution&gt;<br class=""></blockquote>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class=""></blockquote><br class="">-- <br class="">-Dave<br class=""></div></div></blockquote></div><br class=""></body></html>