<div style="white-space:pre-wrap">As a drive by... I think the follow are a little more consistent with the other names.<br><br>invertedIntersection & invertedIntersect</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Feb 15, 2016 at 5:59 PM Ricardo Parada via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> 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">Hi Tony,<div><br></div><div>Is “inverted" a well known term for sets? </div><div><br></div><div>If the default argument is a problem for protocols then perhaps this alternative:</div><div><br></div><div><b>Non-mutable (noun-based)</b></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="Consolas" style="font-size:12px">let union = <span style="white-space:pre-wrap">                        </span>a.union(b)</font></div><div><font face="Consolas"><span style="font-size:12px">let intersection = </span><span style="font-size:12px;white-space:pre-wrap">                </span><span style="font-size:12px">a.intersection(b)</span></font></div><div><font face="Consolas"><span style="font-size:12px">let difference = </span><span style="font-size:12px;white-space:pre-wrap">                </span><span style="font-size:12px">a.difference(b)</span></font></div><div><div><font face="Consolas"><span style="font-size:12px">let symmetricDifference = </span><span style="font-size:12px;white-space:pre-wrap">        </span><span style="font-size:12px">a.symmetricDifference(b)</span><span style="font-size:12px;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// alternative 1</span></font></font></div></div><div><div><font face="Consolas"><span style="font-size:12px">let symmetricDifference =</span><span style="font-size:12px;white-space:pre-wrap">        </span><span style="font-size:12px">a.intersectionComplement(b)</span><span style="font-size:12px;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// alternative 2</span></font></font></div></div><div><div><font face="Consolas"><span style="font-size:12px">let symmetricDifference = </span><span style="font-size:12px;white-space:pre-wrap">        </span><span style="font-size:12px">a.unionWithoutIntersection(b)</span><span style="font-size:12px;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// alternative 3</span></font></font></div></div><div><div><font face="Consolas"><span style="font-size:12px">let symmetricDifference = </span><span style="font-size:12px;white-space:pre-wrap">        </span><span style="font-size:12px">a.unionMinusIntersection(b)</span><span style="font-size:12px;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// atternative 4</span></font></font></div></div></blockquote><div><div></div></div><div><div><div><br></div></div></div><div><b>Mutable (verb-based)</b></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="Consolas"><font size="2">set.merge(membersIn: someSet)</font><span style="font-size:small;white-space:pre-wrap">                        </span><font color="#77bb41"><span style="font-size:12px">// union in-place</span></font></font></div></div><div><div><font face="Consolas"><font size="2">set.remove(membersNotIn: someSet)</font><span style="font-size:small;white-space:pre-wrap">                </span><font color="#77bb41"><span style="font-size:12px">// intersection in-place</span></font></font></div></div><div><div><font face="Consolas"><font size="2">set.remove(membersIn: someSet)</font><span style="font-size:small;white-space:pre-wrap">                        </span><font color="#77bb41"><span style="font-size:12px">// difference in-place</span></font></font></div></div><div><div><div><div><font face="Consolas"><font size="2">set.merge(membersRemovingIntersection: someSet)</font><span style="font-size:small;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// symmetric difference in-place</span></font></font></div></div></div></div></blockquote><div><div><div><div><font face="Consolas" size="2"><br></font></div><div>I considered and discarded all the following for symmetric difference in-place:</div><div><br></div></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><div><div><div><font face="Consolas"><strike style="font-size:small">set.merge(membersWithIntersectionRemoved: someSet)</strike><span style="font-size:small;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// Not clear in my opinion</span></font></font></div></div></div></div></div></div><div><div><div><div><font face="Consolas"><strike style="font-size:small">set.merge(membersRemovingIntersectionWith: someSet)</strike><span style="font-size:small;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// The With seems not necessary</span></font></font></div></div></div></div><div><div><div><strike style="font-family:Consolas;font-size:small">set.merge(removingMembersInCommonWith: someSet)</strike><span style="font-family:Consolas;font-size:small;white-space:pre-wrap">                </span><font color="#77bb41" face="Consolas"><span style="font-size:12px">// Two verbs next to each other?</span></font></div></div></div><div><div><div><strike style="font-family:Consolas;font-size:small">set.merge(allMembersRemovingIntersectionWith: someSet)</strike><span style="font-family:Consolas;font-size:small;white-space:pre-wrap">        </span><font color="#77bb41" face="Consolas"><span style="font-size:12px">// Long and not more clear</span></font></div></div></div><div><div><div><strike style="font-family:Consolas;font-size:small">set.merge(allRemovingMembersInCommon: someSet)</strike><span style="font-family:Consolas;font-size:small;white-space:pre-wrap">                </span><font color="#77bb41" face="Consolas"><span style="font-size:12px">// All what?</span></font></div></div></div><div><div><div><strike style="font-family:Consolas;font-size:small">set.merge(allMembersRemovingIntersection: someSet)</strike><span style="font-family:Consolas;font-size:small;white-space:pre-wrap">        </span><font color="#77bb41" face="Consolas"><span style="font-size:12px">// Clear but longer</span></font></div></div></div><div><div><div><font face="Consolas"><strike style="font-size:small">set.merge(membersRemovingIntersectionWith: someSet)</strike><span style="font-size:small;white-space:pre-wrap">        </span><font color="#77bb41"><span style="font-size:12px">// With not necessary</span></font></font></div></div></div></blockquote><div><div><div><div><div><div></div></div></div><div><div></div></div></div><div><div><div></div></div></div></div><div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div></div><div><div></div></div><div><div><div></div></div></div><div><div><div><br></div></div></div><div><br></div></div><div><br></div><div><br></div><div><div><blockquote type="cite"><div>On Feb 14, 2016, at 7:35 PM, Tony Parker <<a href="mailto:anthony.parker@apple.com" target="_blank">anthony.parker@apple.com</a>> wrote:</div><br><div><div style="word-wrap:break-word">Hi Ricardo,<div><br></div><div>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><br></div><div>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><br></div><div>var s1 = /// … some kind of SetAlgebraType, where func merge(other: Self, removingMembersInCommon: Bool = true)</div><div>var s2 = /// … some other kind of SetAlgebraType, where func merge(other: Self, removingMembersInCommon: Bool = false)</div><div><br></div><div>s1.merge(s2) // xor</div><div>s2.merge(s1) // union</div><div><br></div><div>It is possible to set the default in a protocol extension, but both union and exclusiveOr are abstract in today’s SetAlgebraType.</div><div><br></div><div>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><br></div><div>Here is another idea that we are considering:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">func</span><span> intersected(other: </span><span style="color:#703daa">Self</span><span>) -> </span><span style="color:#703daa">Self // was: intersect</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#703daa"><span style="color:rgb(187,44,162)">mutating</span><span> </span><span style="color:rgb(187,44,162)">func</span><span> intersect(other: </span><span>Self</span><span>) // was: intersectInPlace</span></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#703daa"><span><span style="color:rgb(187,44,162)">func</span><span> invertedIntersection(other: </span><span style="color:rgb(112,61,170)">Self</span><span>) -> </span><span style="color:rgb(112,61,170)">Self // was: exclusiveOr</span></span></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#703daa"><span><span style="color:rgb(112,61,170)"><span style="color:rgb(187,44,162)">mutating</span><span> </span><span style="color:rgb(187,44,162)">func</span><span> invertIntersection(other: </span><span>Self</span><span>) // was: exclusiveOrInPlace</span></span></span></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div>- Tony</div><div><br></div><div><div><blockquote type="cite"><div>On Feb 14, 2016, at 2:36 PM, Ricardo Parada via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div dir="auto"><div>Hi David,</div><div><br></div><div>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><br></div><div>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><br></div><div>Ricardo Parada</div><div><br></div><div><br></div><div>On Feb 14, 2016, at 11:52 AM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><font face="Menlo">a.members(notIn: b)</font></div><div></div></blockquote></div></div></blockquote></div></div></div></div></blockquote></div></div></div><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div><div style="word-wrap:break-word"><div><div><blockquote type="cite"><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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div></div></div></div></blockquote></div></div></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>