<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>I also prefer (2). Isn't "union", "intersection", ... a "Term of Art"? See the guidelines under "<strong style="box-sizing: border-box; background-color: rgba(255, 255, 255, 0);">Stick to the established meaning</strong>".</div><div><br></div><div>So we should stick to the mathematical naming.</div><div><br></div><div>Since these terms almost always return a new instance we should have an obvious mutating version with an "inPlace" suffix.</div><div><br></div><div>- Maximilian</div><div><br>Am 14.02.2016 um 22:37 schrieb Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br><br></div><blockquote type="cite"><div>From a 10,000-ft view, I'd suggest that the noun/verb rule consistently runs into a problem with mathematical terms.<br><br>In general, mathematical functions don't have verb forms. You 'compute' the reciprocal, or 'find' the reciprocal, or 'take' the reciprocal, you don't 'reciprocate' or 'reciprocalize'. Likewise for trigonometric functions, etc. Nor can you really 'cross produce'...<br><br>So consistent is this trend that where two words might be noun/verb counterparts, like intersect/intersection and transform/transformation, common math usage treats both as acceptable nouns.<br><br>In colloquial usage, you might verb the noun, but then by definition the verb and noun become the same. Then, to generate a noun phrase/participle/etc. that looks different from the verb, you have to noun-ify the verbed noun.<br><br>Without an exception for mathematical function names, the only solution to fulfill these new Swift rules are clobbering the well-known math name or not using the math name at all. Indeed all proposed solutions so far come down to one of four options, either applied globally or only to sets for now, punting the rest down the road:<br><br>(1) Abandon the rule, making a new one (e.g.: .=)<br>(2) Make an exception to the rule for math function names<br>(3) Generate the least offensive noun-ified verbed nouns based on math function names<br>(4) Don't use math function names<br><br>(1) is off the table, according to the core team. My vote at this point is for (2), and I see that a few others have voiced that opinion. It'd be nice to get a sense from the core team if that is even a possibility. (3) has elicited a lot of discussion and visceral reactions. (4) might be workable for sets alone but surely can't be a generalized solution for all mathematical concepts to be encountered in Swift.<br><div class="gmail_quote"><div dir="ltr">On Sun, Feb 14, 2016 at 3:14 PM Tyler Fleming Cloutier 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 Feb 14, 2016, at 12:48 PM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@apple.com</a>&gt; wrote:</div><br><div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">on Sun Feb 14 2016, Tyler Fleming Cloutier &lt;</span><a href="http://cloutiertyler-at-aol.com/" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">cloutiertyler-AT-aol.com</a><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">&gt; wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant: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" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant: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">On Feb 14, 2016, at 8:27 AM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@apple.com</a>&gt; wrote:<br><br><br>on Sat Feb 13 2016, Tyler Fleming Cloutier &lt;<a href="http://cloutiertyler-at-aol.com" target="_blank">cloutiertyler-AT-aol.com</a>&gt; wrote:<br><br><blockquote type="cite">I would, personally, be very careful about discarding the mathematical<br>terms since they are so widely used and understood.<br></blockquote><br>IMO it's better to leave them aside than to use them in “creative” ways<br>that might be misleading.<br><br></blockquote><br>Agreed. I’m all for that.<br><br><blockquote type="cite"><blockquote type="cite">One issue is that it’s going to be hard to search for the operation I<br>want considering I won’t be looking for "func<br>invertingMembershipOfContentsOf(other: Self) -&gt; Self”. I’m concerned<br>people are going to have to do mental gymnastics to build the map from<br>math term to Swift function every time they want to look for a set<br>operation method. “func invertingMembershipOfContentsOf(other: Self)<br>-&gt; Self” doesn’t exactly seem to fit in the commonly held Venn diagram<br>mental model of set operations. You could always have a documentation<br>comment that specifies the mathematical term so that people didn’t<br>have to double check themselves every time.<br><br>That being said, if the autocomplete issue is not a concern, I’m of<br>the opinion that the names Ricardo proposed are short, clear, and are<br>not so hard to fit to my Venn diagram mental model.<br></blockquote><br>+1<br><br><blockquote type="cite">However, I tend to think that if there has to be this much dancing to<br>name a set of fundamental operations, the guidelines aren’t<br>accomplishing their goal.<span>&nbsp;</span><br></blockquote><br>I can't disagree.<br><br><blockquote type="cite">It’s going to make it that much harder for people do design their own<br>APIs. I'm having quite a time trying to conform Mattt’s Surge API to<br>the guidelines.<br></blockquote><br>Please explain in detail.&nbsp; Without details we don't know what's wrong<br>with the guidelines.<br></blockquote><br>Ah, I apologize. I’ve gone into detail about this API on the list<br>before, but I should have included the details here.<br><br>Here are my previous posts:<br><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007560.html" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007560.html</a><br>&lt;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007560.html" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007560.html</a>&gt;<br><br>Basically the issues come down to the following. The Accelerate<br>framework typical operates in a non-mutating way. This means that my<br>API only has non mutating member functions and I should use the ed/ing<br>rule according to the guidelines to name my methods.<br><br>This is very difficult for some methods. I’m able to frequently get<br>around the problem for things like “sin” or “arctan” by keeping them<br>as global functions, but I can’t do that for a number of<br>methods. Consider:<br><br>remainder<br>dot (returns a scalar, thus there can’t be a mutating version, so<br>should I just call it dot? Guidelines don’t really comment on this)<br>mean (same as above)<br>cross<br>reciprocal<br>threshold<br>copysign<br>fastFourierTransform<br>pow (arguably the method version should be called raisedTo)<br><br>I could force all these to be global functions only, but these are not<br>as cut and dry as “sin” or “arctan”. I feel like I’d be splitting my<br>API up into two parts just based on the fact that it’s difficult to<br>use the ed/ing rule. That makes it very difficult for users to find<br>certain functions in my API.<br><br>In this case there are no corresponding mutating operations because of<br>the way Accelerate works, but one could certainly imagine an API with<br>mutating counterparts. The way I read the guidelines, they seem to<br>imply I should use ed/ing regardless of whether there is a mutating<br>counterpart. I’d love to hear your thoughts on this.<br></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">As long as the ones without side effects read as noun phrases and the</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">ones with side-effects read as verb phrases, you're good.&nbsp; No ed/ing</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">needed.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>Ah yes, you are very right. Still what would the mutating versions of remainder, fastFourierTransform, or reciprocal be? getRemainder? applyFastFourierTransform? reciprocate? I suppose those aren’t so bad.</div><div><br></div><div>I also suppose cross could become x.crossProduct(with: y) and copysign, x.copyingSign(of: y). Seems a little verbose, but it does the job.</div><div><br></div><div>Thanks,</div><div><br></div><div>Tyler</div></div></div><div style="word-wrap:break-word"><div><div><br></div><br><blockquote type="cite"><div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant: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" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><br>Thanks,<br><br>Tyler<br><br><blockquote type="cite"><br><blockquote type="cite"><br>Tyler<br><br><blockquote type="cite">On Feb 13, 2016, at 9:09 PM, Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br>Hi Dave,<br><br>I would be okay with staying away from the mathematical terms<br>similar to what you are suggesting except that the union can still<br>be made more concise if you use merged / merge for the base name and<br>shorten the labels to a bare minimum without loosing clarity.&nbsp; In<br>addition, the merge can have a second parameter with a default to<br>false in order to implement the symmetric difference<br>(a.k.a. exclusive or).&nbsp; Recall that symmetric difference is the<br>union of two sets and then removing the intersection (or members in<br>common).&nbsp; I think it looks perfect (concise and clear).&nbsp; What does<br>everybody else think?<br><br>Non-mutable<br><br>let union =<span>&nbsp;</span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>a.merged(with: b)<br>let intersection =<span>&nbsp;</span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>a.members(in: b)<br>let difference =<span>&nbsp;</span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>a.removingMembers(in: b)<br>let symmetricDifference =<span>&nbsp;</span><span style="white-space:pre-wrap">        </span>a.merged(with: b, removingMembersInCommon: true)<br><br>Mutable (In-Place)<br><br>a.merge(with: b)<span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>// union in-place<br>a.removeMembers(notIn: b)<span style="white-space:pre-wrap">        </span>// intersect in-place<br>a.removeMembers(in: b)<span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>// difference in-place<br>a.merge(with: b, removeMembersInCommon: true)<span style="white-space:pre-wrap">        </span>// symmetric difference in-place<br><br>Ricardo Parada<br><br><br><blockquote type="cite">On Feb 13, 2016, at 1:16 PM, Dave Abrahams via swift-evolution<br>&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">mailto:swift-evolution@swift.org</a>&gt;&gt;<br>wrote:<br><br><br>on Fri Feb 12 2016, Ricardo Parada &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br><br><blockquote type="cite">Hi all,<br><br>I can’t make up my mind.&nbsp; Let me propose two different alternatives<br>that I’m not sure if they have been considered:<br><br>ALTERNATIVE 1<br><br>Non-mutable (noun-based)<br><br>- &nbsp;func union(other: Self) -&gt; Self<br>+ &nbsp;func union(other: Self) -&gt; Self<span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>Assumes union is a noun, i.e. not a verb<br><br>- &nbsp;func intersect(other: Self) -&gt; Self<br>+ &nbsp;func intersection(other: Self) -&gt; Self<br><br>- &nbsp;func subtract(other: Self) -&gt; Self<br>+ &nbsp;func subtraction(other: Self) -&gt; Self<br><br>- &nbsp;func exclusiveOr(other: Self) -&gt; Self<br>+ &nbsp;func symmetricSubtraction(other: Self) -&gt; Self<br><br>Mutable (verb-based)<br><br>- &nbsp;mutating func unionInPlace(other: Self)<br>+ &nbsp;mutating func unite(other: Self)<br><br>- &nbsp;mutating func intersectInPlace(other: Self)<br>+ &nbsp;mutating func intersect(other: Self)<br><br>- &nbsp;mutating func subtractInPlace(other: Self)<br>+ &nbsp;mutating func subtract(other: Self)<br><br>- &nbsp;mutating func exclusiveOrInPlace(other: Self)<br>+ &nbsp;mutating func symmetricSubtract(other: Self)<br><br>Comments:<span>&nbsp;</span><br><br>With this alternative we keep the union name which I assume is<br>popular.&nbsp; However, one has to accept unite as a verb (for the mutable<br>version) as I wanted all the mutable methods use verbs for<br>consistency.&nbsp; I think unite is acceptable because it can be found in<br>the dictionary and it is a verb.<br><br>Notice that all the non-mutable methods use nouns: union,<br>intersection, subtraction and symmetricSubtraction.<br><br>I understand some may oppose to symmetricSubtraction saying that<br>symmetricSubraction is not as common as "exclusive or".&nbsp; However,<br>using symmetricSubtraction is consistent with subtraction and it hints<br>to a variation of the “subtraction" operation.&nbsp; We will get used to it<br>quickly / easily.<br><br>The mutable methods all use verbs: &nbsp;unite, intersect, subtract and symmetricSubtract.<br><br>ALTERNATIVE 2<br><br>Non-mutable<br><br>- &nbsp;func union(other: Self) -&gt; Self<br>+ &nbsp;func adding(other: Self) -&gt; Self<br><br>- &nbsp;func intersect(other: Self) -&gt; Self<br>+ &nbsp;func intersecting(other: Self) -&gt; Self<br><br>- &nbsp;func exclusiveOr(other: Self) -&gt; Self<br>+ &nbsp;func exclusiveOring(other: Self) -&gt; Self<br><br>- &nbsp;func subtract(other: Self) -&gt; Self<br>+ &nbsp;func removing(other: Self) -&gt; Self<br><br>Mutable<br><br>- &nbsp;mutating func unionInPlace(other: Self)<br>+ &nbsp;mutating func add(other: Self)<br><br>- &nbsp;mutating func intersectInPlace(other: Self)<br>+ &nbsp;mutating func intersect(other: Self)<br><br>- &nbsp;mutating func exclusiveOrInPlace(other: Self)<br>+ &nbsp;mutating func exclusiveOr(other: Self)<br><br>- &nbsp;mutating func subtractInPlace(other: Self)<br>+ &nbsp;mutating func remove(other: Self)<br><br>Comments: This alternative gives up on union in favor or add.&nbsp; Many<br>may not like this, that is why I have it as the second alternative.<br>It brings back exclusiveOr and treats it as a verb.&nbsp; Some may argue<br>that exclusiveOr is a noun for the "exclusive or" operation.<br></blockquote><br>If we are going to force Set fit the naming guidelines, I would prefer<br>to stay away from the mathematical terms altogether.<br><br>func insertingContentsOf(other: Self) -&gt; Self &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// union<br>mutating func insertContentsOf(other)<br><br>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>mutating func removeMembers(notIn: other)<br><br>func removingMembersAndAddingNonMembers(in other: Self) -&gt; Self // symmetric difference<br>mutating func removeMembersAndAddingNonMembers(in other: Self)<br><br>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>mutating func removeMembers(in other: Self)<br><br>If it would help with clarity, we could replace "in" with "foundIn"<br>above.<br><br>--<span>&nbsp;</span><br>-Dave<br><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">mailto:swift-evolution@swift.org</a>&gt;<br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>&lt;<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a>&gt;<br></blockquote>_______________________________________________<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></blockquote><br></blockquote><br>--<span>&nbsp;</span><br>-Dave<br></blockquote><br></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">--<span>&nbsp;</span></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">-Dave</span></div></blockquote></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>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>