<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="">Hi Tony,<div class=""><br class=""></div><div class="">Is “inverted" a well known term for sets? </div><div class=""><br class=""></div><div class="">If the default argument is a problem for protocols then perhaps this alternative:</div><div class=""><br class=""></div><div class=""><b class="">Non-mutable (noun-based)</b></div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Consolas" style="font-size: 12px;" class="">let union = <span class="Apple-tab-span" style="white-space: pre;">                        </span>a.union(b)</font></div><div class=""><font face="Consolas" class=""><span style="font-size: 12px;" class="">let intersection = </span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">                </span><span style="font-size: 12px;" class="">a.intersection(b)</span></font></div><div class=""><font face="Consolas" class=""><span style="font-size: 12px;" class="">let difference = </span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">                </span><span style="font-size: 12px;" class="">a.difference(b)</span></font></div><div class=""><div class=""><font face="Consolas" class=""><span style="font-size: 12px;" class="">let symmetricDifference = </span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><span style="font-size: 12px;" class="">a.symmetricDifference(b)</span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// alternative 1</span></font></font></div></div><div class=""><div class=""><font face="Consolas" class=""><span style="font-size: 12px;" class="">let symmetricDifference =</span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><span style="font-size: 12px;" class="">a.intersectionComplement(b)</span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// alternative 2</span></font></font></div></div><div class=""><div class=""><font face="Consolas" class=""><span style="font-size: 12px;" class="">let symmetricDifference = </span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><span style="font-size: 12px;" class="">a.unionWithoutIntersection(b)</span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// alternative 3</span></font></font></div></div><div class=""><div class=""><font face="Consolas" class=""><span style="font-size: 12px;" class="">let symmetricDifference = </span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><span style="font-size: 12px;" class="">a.unionMinusIntersection(b)</span><span class="Apple-tab-span" style="font-size: 12px; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// atternative 4</span></font></font></div></div></blockquote><div class=""><div class=""></div></div><div class=""><div class=""><div class=""><br class=""></div></div></div><div class=""><b class="">Mutable (verb-based)</b></div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Consolas" class=""><font size="2" class="">set.merge(membersIn: someSet)</font><span class="Apple-tab-span" style="font-size: small; white-space: pre;">                        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// union in-place</span></font></font></div></div><div class=""><div class=""><font face="Consolas" class=""><font size="2" class="">set.remove(membersNotIn: someSet)</font><span class="Apple-tab-span" style="font-size: small; white-space: pre;">                </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// intersection in-place</span></font></font></div></div><div class=""><div class=""><font face="Consolas" class=""><font size="2" class="">set.remove(membersIn: someSet)</font><span class="Apple-tab-span" style="font-size: small; white-space: pre;">                        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// difference in-place</span></font></font></div></div><div class=""><div class=""><div class=""><div class=""><font face="Consolas" class=""><font size="2" class="">set.merge(membersRemovingIntersection: someSet)</font><span class="Apple-tab-span" style="font-size: small; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// symmetric difference in-place</span></font></font></div></div></div></div></blockquote><div class=""><div class=""><div class=""><div class=""><font face="Consolas" size="2" class=""><br class=""></font></div><div class="">I considered and discarded all the following for symmetric difference in-place:</div><div class=""><br class=""></div></div></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><font face="Consolas" class=""><strike style="font-size: small;" class="">set.merge(membersWithIntersectionRemoved: someSet)</strike><span class="Apple-tab-span" style="font-size: small; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// Not clear in my opinion</span></font></font></div></div></div></div></div></div><div class=""><div class=""><div class=""><div class=""><font face="Consolas" class=""><strike style="font-size: small;" class="">set.merge(membersRemovingIntersectionWith: someSet)</strike><span class="Apple-tab-span" style="font-size: small; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// The With seems not necessary</span></font></font></div></div></div></div><div class=""><div class=""><div class=""><strike style="font-family: Consolas; font-size: small;" class="">set.merge(removingMembersInCommonWith: someSet)</strike><span class="Apple-tab-span" style="font-family: Consolas; font-size: small; white-space: pre;">                </span><font color="#77bb41" face="Consolas" class=""><span style="font-size: 12px;" class="">// Two verbs next to each other?</span></font></div></div></div><div class=""><div class=""><div class=""><strike style="font-family: Consolas; font-size: small;" class="">set.merge(allMembersRemovingIntersectionWith: someSet)</strike><span class="Apple-tab-span" style="font-family: Consolas; font-size: small; white-space: pre;">        </span><font color="#77bb41" face="Consolas" class=""><span style="font-size: 12px;" class="">// Long and not more clear</span></font></div></div></div><div class=""><div class=""><div class=""><strike style="font-family: Consolas; font-size: small;" class="">set.merge(allRemovingMembersInCommon: someSet)</strike><span class="Apple-tab-span" style="font-family: Consolas; font-size: small; white-space: pre;">                </span><font color="#77bb41" face="Consolas" class=""><span style="font-size: 12px;" class="">// All what?</span></font></div></div></div><div class=""><div class=""><div class=""><strike style="font-family: Consolas; font-size: small;" class="">set.merge(allMembersRemovingIntersection: someSet)</strike><span class="Apple-tab-span" style="font-family: Consolas; font-size: small; white-space: pre;">        </span><font color="#77bb41" face="Consolas" class=""><span style="font-size: 12px;" class="">// Clear but longer</span></font></div></div></div><div class=""><div class=""><div class=""><font face="Consolas" class=""><strike style="font-size: small;" class="">set.merge(membersRemovingIntersectionWith: someSet)</strike><span class="Apple-tab-span" style="font-size: small; white-space: pre;">        </span><font color="#77bb41" class=""><span style="font-size: 12px;" class="">// With not necessary</span></font></font></div></div></div></blockquote><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""></div></div></div><div class=""><div class=""></div></div></div><div class=""><div class=""><div class=""></div></div></div></div><div class=""><div class=""><div class=""></div></div><div class=""><div class=""></div></div><div class=""><div class=""></div></div><div class=""><div class=""></div></div></div><div class=""><div class=""></div></div><div class=""><div class=""><div class=""></div></div></div><div class=""><div class=""><div class=""><br class=""></div></div></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Feb 14, 2016, at 7:35 PM, Tony Parker <<a href="mailto:anthony.parker@apple.com" class="">anthony.parker@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Ricardo,<div class=""><br class=""></div><div class="">Your idea for exclusiveOr as a default arg had a lot of appeal to me at first, but when I went to go try it I realized that it doesn’t appear to be possible to enforce a value for a default argument in a protocol (which is the root of the API we’re talking about, in SetAlgebraType).</div><div class=""><br class=""></div><div class="">All adopters of the protocol would be required to provide the default value in their implementation. It’s less than ideal to me to have each type that adopts the protocol decide what the default is, because a mistake would lead to confusing behavior:</div><div class=""><br class=""></div><div class="">var s1 = /// … some kind of SetAlgebraType, where func merge(other: Self, removingMembersInCommon: Bool = true)</div><div class="">var s2 = /// … some other kind of SetAlgebraType, where func merge(other: Self, removingMembersInCommon: Bool = false)</div><div class=""><br class=""></div><div class="">s1.merge(s2) // xor</div><div class="">s2.merge(s1) // union</div><div class=""><br class=""></div><div class="">It is possible to set the default in a protocol extension, but both union and exclusiveOr are abstract in today’s SetAlgebraType.</div><div class=""><br class=""></div><div class="">Of course the blame lies on the implementation of s1 here, but this approach does introduce a unique kind of sharp edge that we cannot warn about at compile time. I think that this is a consequence of putting something fundamental to the behavior of the method into an argument instead of into the base name.</div><div class=""><br class=""></div><div class="">Here is another idea that we are considering:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> intersected(other: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Self // was: intersect</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">mutating</span><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="" class=""> intersect(other: </span><span style="font-variant-ligatures: no-common-ligatures;" class="">Self</span><span style="" class="">) // was: intersectInPlace</span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class=""><span style="" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> invertedIntersection(other: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Self // was: exclusiveOr</span></span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class=""><span style="" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">mutating</span><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="" class=""> invertIntersection(other: </span><span style="font-variant-ligatures: no-common-ligatures;" class="">Self</span><span style="" class="">) // was: exclusiveOrInPlace</span></span></span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div class="">- Tony</div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 14, 2016, at 2:36 PM, Ricardo Parada via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">Hi David,</div><div class=""><br class=""></div><div class="">It had to read your code a few times to realize what you had changed. :-) It's subtle and makes the names more consistent. I agree with your suggestion. </div><div class=""><br class=""></div><div class="">As for whether or not the 'with' label should be removed from the mutable merge, I think it would work well either way. However the code is more concise without it and still reads well. </div><div class=""><br class=""></div><div class="">Ricardo Parada</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">On Feb 14, 2016, at 11:52 AM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><font face="Menlo" class="">a.members(notIn: b)</font></div><div class=""></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>