The inPlace proposal is excellent. As suggested something like x.=f() would be perfect to distinguish mutating methods .Something I don&#39;t like from the API design guidelines is that non mutating methods like enumerate would be become enumerated. In my mind enumerate is a word of art and I don&#39;t ever think of it as muting so having to always use enumerated in the future seems weird. Also having to ed/ing non mutating methods seems to make mutating methods more important. <div><br><div>//non mutating suggestion</div><div>x.sort()</div>x.split()<br><div><br></div><div>//other ideas for mutating methods names</div><div>x.sort*()</div><div>x.sort&amp;() // I like &amp; the most</div>x.split&amp;()<br><div>x.sort@()<br><div><br></div>By marking a method with a special character at the end, the reader would know that the method mutates. <br><div><div><div><br>On Saturday, January 23, 2016, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
on Fri Jan 22 2016, David Owens II &lt;<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-evolution@swift.org&#39;)">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt;&gt; Compensate For Weak Type Information as needed to clarify a parameter’s role.<br>
&gt;&gt;<br>
&gt;&gt; Especially when a parameter type is NSObject, Any, AnyObject, or a<br>
&gt;&gt; fundamental type such Int or String, type information and context at<br>
&gt;&gt; the point of use may not fully convey intent. In this example, the<br>
&gt;&gt; declaration may be clear, but the use site is vague:<br>
&gt;&gt;<br>
&gt;&gt; func add(observer: NSObject, for keyPath: String)<br>
&gt;&gt; grid.add(self, for: graphics) // vague<br>
&gt;&gt;<br>
&gt;&gt; To restore clarity, precede each weakly-typed parameter with a noun describing its role:<br>
&gt;&gt;<br>
&gt;&gt; func addObserver(_ observer: NSObject, forKeyPath path: String)<br>
&gt;&gt; grid.addObserver(self, forKeyPath: graphics) // clear<br>
&gt;<br>
&gt; I don’t understand why to compensate for weak type information we put<br>
&gt; some of that compensation in the name of the function and other parts<br>
&gt; of it in the [external] name of the parameter.<br>
<br>
IIUC, some people feel strongly that it would be really strange and<br>
nonuniform to have a substantial fraction of methods with an argument<br>
label on the first argument unless that percentage was nearly 100.<br>
<br>
[I don&#39;t know whether there&#39;s an &quot;official terminology&quot; for these names,<br>
but we&#39;ve been calling them &quot;argument labels&quot; in the naming discussions.<br>
Note that the (&quot;internal&quot;) parameter names aren&#39;t strictly internal as<br>
they get used in documentation comments, and should be chosen<br>
accordingly.  So, I&#39;m using the terms &quot;argument label&quot; and &quot;parameter<br>
name&quot;.]<br>
<br>
&gt; If we were going to reference functions like this:<br>
&gt; addObserver:forKeyPath, then I can understand it. But that’s not the<br>
&gt; plan of record, it’s to do this: addObserver(_:forKeyPath).<br>
<br>
That&#39;s an interesting argument.<br>
<br>
&gt; Regardless of the default naming scheme, it seems like the rule should<br>
&gt; be to use external names to clarify that parameters role.<br>
&gt;<br>
&gt; func add(observer observer: NSObject, forKeyPath path: String)<br>
&gt; grid.add(observer: self, forKeyPath: graphics)<br>
&gt;<br>
&gt; This promotes a very clear and consistent rule: weak type information<br>
&gt; should be clarified by the parameter’s external name. There are no<br>
&gt; exceptions for the first parameter.<br>
<br>
That seems very clean to me.<br>
<br>
&gt; Otherwise, it seems like there is super fine line between this rule<br>
&gt; and the next one below.<br>
&gt;<br>
&gt; Additionally, this also alleviates my concerns with the default<br>
&gt; parameter have _ as the external name by default because this<br>
&gt; addresses the case when it would be desirable to have that<br>
&gt; name.<br>
<br>
Sorry, I don&#39;t understand what you&#39;re getting at here.<br>
<br>
&gt; Further, the case below handles the case when it’s not.<br>
&gt;<br>
&gt;&gt; Omit Needless Words. Every word in a name should convey salient information at the use site.<br>
&gt;&gt;<br>
&gt;&gt; More words may be needed to clarify intent or disambiguate meaning,<br>
&gt;&gt; but those that are redundant with information the reader already<br>
&gt;&gt; possesses should be omitted. In particular, omit words that merely<br>
&gt;&gt; repeat type information:<br>
&gt;&gt;<br>
&gt;&gt; public mutating func removeElement(member: Element) -&gt; Element?<br>
&gt;&gt; allViews.removeElement(cancelButton)<br>
&gt;&gt;<br>
&gt;&gt; In this case, the word Element adds nothing salient at the call site. This API would be better:<br>
&gt;&gt;<br>
&gt;&gt; public mutating func remove(member: Element) -&gt; Element?<br>
&gt;&gt; allViews.remove(cancelButton) // clearer<br>
&gt;&gt;<br>
&gt;&gt; Occasionally, repeating type information is necessary to avoid<br>
&gt;&gt; ambiguity, but in general it is better to use a word that describes<br>
&gt;&gt; a parameter’s role rather than its type. See the next item for<br>
&gt;&gt; details.<br>
&gt;<br>
&gt; The description here seems to overlap with the “Compensate for Weak<br>
&gt; Type Information” rule, especially with the clause: “repeating type<br>
&gt; information”. It may be better to re-work the example to be<br>
&gt; `removeItem(member: Element)` to make this distinction more clear that<br>
&gt; it’s not type information being removed.<br>
<br>
Oh, great point!<br>
<br>
&gt; Also, by clarifying that statement, the above rule change I suggested<br>
&gt; would be consistent. Type information clarification goes into the<br>
&gt; external parameter name, functionality clarification goes into the<br>
&gt; function name. Those are hard-n-fast rules that are straight-forward.<br>
<br>
I like &#39;em, FWIW.<br>
<br>
&gt;&gt; Be Grammatical<br>
&gt;&gt;<br>
&gt;&gt; When a mutating method is described by a verb, name its non-mutating<br>
&gt;&gt; counterpart according to the “ed/ing” rule, e.g. the non-mutating<br>
&gt;&gt; versions of x.sort() and x.append(y) are x.sorted() and<br>
&gt;&gt; x.appending(y).<br>
&gt;<br>
&gt; Is this guideline suggesting that we should design our APIs to<br>
&gt; generally have both mutating and non-mutaging counterparts?<br>
<br>
Definitely not.<br>
<br>
&gt; As other have pointed out, this is also very hard to do all the<br>
&gt; time. I think the alternatives are worse.<br>
<br>
The alternatives to always creating mutating/nonmutating pairs?  What<br>
alternatives have you considered, and what do you see the consequences<br>
to be?<br>
<br>
&gt; It would be nice if there were a way to annotate all member functions<br>
&gt; as mutating/non-mutating to really by-pass this ambiguity.<br>
<br>
I don&#39;t know what you mean by that.  Can you explain?<br>
<br>
FWIW, there are potential language-level approaches to this problem<br>
(e.g. <a href="https://github.com/apple/swift/blob/master/docs/proposals/Inplace.rst" target="_blank">https://github.com/apple/swift/blob/master/docs/proposals/Inplace.rst</a>),<br>
but in the absence of language features, it&#39;s something we need a<br>
convention for.<br>
<br>
--<br>
-Dave<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;swift-evolution@swift.org&#39;)">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></div></div></div></div></div>