I do believe, if we&#39;re going to try to go down the route of correctness, that A \ B is generally spoken of as the complement of B in A, which I guess could be written in Swift as `a.complement(of: b)`. However, that doesn&#39;t read too well and I don&#39;t think it clarifies anything.<br><br>Alternatively, and this would be a bigger change but would be unambiguous and correct, we could have it as `b.complement(in: a)`, which has the added but practically useless virtue that a hypothetical universal complement could be named in a consistent way as `b.complement()`.<br><br>Difference does seem to be the consensus word among most programming languages for this method, and in Python it really is just `a.difference(b)`. I don&#39;t think it&#39;s ever referred to as &quot;difference from&quot;, and I would not know if `a.formDifference(from: b)` denotes A \ B or B \ A without looking it up.<br><br>So, I guess, I&#39;d prefer subtract over &quot;difference from&quot;, as neither is really mathematically correct and at least the former is unambiguous. If the core team is willing to entertain b.complement(in: a), I&#39;d be +1 on that. At the end of the day, this particular method will have to look different from the others no matter what because it is unique in not being commutative.<br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 28, 2016 at 9:59 PM Dave via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Mar 28, 2016, at 7:34 PM, Erica Sadun &lt;<a href="mailto:erica@ericasadun.com" target="_blank">erica@ericasadun.com</a>&gt; wrote:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br>On Mar 28, 2016, at 6:19 PM, Dave via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div><br><blockquote type="cite">On Mar 25, 2016, at 4:45 PM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@apple.com</a>&gt; wrote:<br><br>on Fri Mar 25 2016,<span> </span><a href="http://davesweeris-at-mac.com/" target="_blank">davesweeris-AT-mac.com</a><span> </span>wrote:<br><br><blockquote type="cite">Can we rename `subtract` to `complement`, since that’s the correct<br>term? At least, I’m assuming that’s what `subtract` means… if not, I’m<br>confused.<br><a href="https://en.wikipedia.org/wiki/Set_(mathematics)#Complements" target="_blank">https://en.wikipedia.org/wiki/Set_(mathematics)#Complements</a><br></blockquote><br>It&#39;s not just “complement,” because that means inverting set membership<br>of everything in a finite domain.  It would have to be “relative<br>complement.”  But “relative complement” lacks the directional<br>implication that plagues terms like “difference,” but not “subtracting.”<br></blockquote><br>Fair points… I accidentally left off the argument label. May I amend my suggestion to &quot;rename `subtract(:)` to `complement(relativeTo:)`”? It just seems to me that if we’re going to claim we’re implementing something, we should adopt as much of its “standard&quot; syntax and terminology as possible. It makes Swift easier to use for those coming from other disciplines, IMHO.<br></div></div></blockquote></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">If you took 100 random developers off the street, and showed them code that said:</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Menlo">set1.formRelativeComplement(set2)</font></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">and</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Menlo">set1.subtracting(set2)</font></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">About 99.5% of them would understand the second better than the first on first read. </div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">The other 0.5 of a developer would be living somewhere near Boulder and growing </div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">his own hemi-pharmaceuticals.</div></div></blockquote></div></div><div style="word-wrap:break-word"><div><div>With my amended suggestion, that would read &quot;<font face="Menlo">set1.formComplement(relativeTo: set2)</font>”. Either way, though, if you’re claiming that “complement(relativeTo:)” or “complementRelativeTo(:)” shouldn’t be used because it’s too unrecognizable compared to the roughly-analogous term “subtract&quot;, then surely “union”, intersection”, and especially “symmetricDifference” all fail that test as well when compared to some very well-known terms:</div><div><font face="Menlo">set1.or(set2)    //union</font></div><div><font face="Menlo">set1.and(set2)   //intersection</font></div><div><span style="font-family:Menlo">set1.xor(set2)   </span><span style="font-family:Menlo">//symmetric difference</span></div><div>(Plus, they work &amp; play well with non-unicode operators.)</div><div><br></div><div>My issue isn’t so much that the proposal doesn’t implement the “correct” mathematical notation, it’s that it uses a very formal-sounding name (&quot;Set Algebra”), and very nearly implements the basic operations of Set Theory (which sounds very similar to “Set Algebra”), but then falls short by renaming just one operation. Although, come to think of it, the proposal is missing `cartesianProduct` as well…  Oh well, at least it’s not in there under a different name. :-)</div></div></div><div style="word-wrap:break-word"><div><div><br></div><div><br></div><div><br></div><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">The problem with subtraction is that there isn&#39;t really a good<span> </span><font face="Menlo">noun/formNoun</font><span> </span>pair</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">for it. </div></div></blockquote></div></div><div style="word-wrap:break-word"><div>...</div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">In all my attempts at trying to brainstorm up a better word that would (1) retain</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">the characteristics of mutating/non-mutating pairing while (2) being easy to read</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">and understand, I could not come up with better than Dave A&#39;s<span> </span><font face="Menlo">subtract/subtracting</font>.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I may not like it aesthetically but when it comes to offering something better,</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I&#39;ve got nothing.</div></div></blockquote></div></div><div style="word-wrap:break-word"><div><div>I think these two statements have the same root cause: Pretty much everyone has heard of subtraction, but the closest most people come to formally thinking about sets is trying to decide who to pick for their fantasy football team. The concept of operating on sets simply isn’t widespread enough for english to have a colloquial word which conveys the required meaning. “Subtract” does come close, but the AFAIK two concepts are only analogous in that subtraction is often first taught from the POV of “imagine a set of x elements, take away y of them, and count how many are left over” (see the first graphic in <a href="https://en.wikipedia.org/wiki/Subtraction" target="_blank">https://en.wikipedia.org/wiki/Subtraction</a>, if that doesn’t ring a bell). The analogy doesn’t really work if your sets are, well, sets, as opposed to visual representations of numbers. The only other “widely-recognized” term that I can think of is “minus” (which I’d prefer over “subtract” because it seems less precisely defined to me). Neither one is a noun, though, so they both break the noun/formNoun pattern.</div><div><br></div><div>Speaking of nouns...</div></div></div><div style="word-wrap:break-word"><div><div><div></div></div><blockquote type="cite"><div><div>That means either breaking the pair into two words that aren&#39;t well matched</div><div>or using a noun that isn&#39;t that amazing, such as <font face="Menlo">difference</font>.</div><div><br></div><div><font face="Menlo">set1.difference(set2)</font></div><div><font face="Menlo">set1.formDifference(set2)</font></div></div></blockquote></div></div><div style="word-wrap:break-word"><div><div>You can gain the requisite “directional implication” Dave Abrahams was talking about by adding some labels:</div><div><font face="Menlo">set1.difference(from: set2)</font></div><div><font face="Menlo">set1.formDifference(from: set2)</font></div></div></div><div style="word-wrap:break-word"><div><div><br></div><div><br></div><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">That said, I&#39;d really like to see a Swift Doc markup that allows you to mark</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">pairs of mutating/nonmutating functions, not from a compiler point of</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">view but in doc markup.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Menlo">/// - nonmutatingVersion: </font></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Menlo">/// - mutatingVersion:</font></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">What group handles expansion of the markup keywords and how can I file a</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">feature request asking for this to be added?</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Thanks,</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">-- E</div></div></blockquote></div></div><div style="word-wrap:break-word"><div></div>+1 :-)</div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>