<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 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 &nbsp;= true)</div><div class="">var s2 = /// … some other kind of SetAlgebraType, where func merge(other: Self, removingMembersInCommon: Bool &nbsp;= 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="">) -&gt; </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="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">&nbsp;intersect(other:&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">Self</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" 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="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" 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="">&nbsp;invertedIntersection(other:&nbsp;</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="">) -&gt;&nbsp;</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="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" 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="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" class="">&nbsp;invertIntersection(other:&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">Self</span><span style="color: rgb(0, 0, 0); font-variant-ligatures: no-common-ligatures;" 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><blockquote type="cite" class=""><div class="">On Feb 14, 2016, at 2:36 PM, Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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. :-) &nbsp;It's subtle and makes the names more consistent. I agree with your suggestion.&nbsp;</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. &nbsp;However the code&nbsp;is more concise without it and still reads well.&nbsp;</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 &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>