<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 18, 2016, at 4:44 PM, Xiaodi Wu 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=""><div dir="ltr" class="">On Sat, Jun 18, 2016 at 4:50 PM, Michael Peternell via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
&gt; Am 17.06.2016 um 07:45 schrieb Charlie Monroe via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:<br class="">
&gt;<br class="">
&gt; Motivational example:<br class="">
&gt;<br class="">
&gt; var urlString = self.urlString<br class="">
&gt; if urlString.hasPrefix("//") {<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp;urlString = "http:" + urlString // urlString needs to be typed twice<br class="">
&gt; }<br class="">
&gt;<br class="">
&gt; While there is currently an easy way to append string using +=, there is no shortcut for prefixing a string. What I propose is adding a =+ operator for prefixing the string:<br class="">
&gt;<br class="">
&gt; urlString =+ "http:"<br class="">
&gt;<br class="">
&gt; Would anyone else find it useful?<br class="">
<br class="">
</span>No. What I would find useful though, is to recognize that addition is not string concatenation. There is a strong convention in mathematics that the "+" symbol should only be used for operations that are commutative. String concatenation is not commutative. (There are more conventions regarding "+", but all of them are respected by numbers, vectors, complex numbers, quaternions, or matrices - just to name a few.)<br class="">
<br class="">
I would like to have a different operator for string concatenation.</blockquote><div class=""><br class=""></div><div class="">I don't see how this would measurably improve Swift code. IIUC, much of the problem with `+` and strings arises from implicit conversions that don't happen in Swift. It's not even possible to write a generic algorithm that accidentally confuses arithmetic `+` and string concatenation `+`, since you would have to retroactively conform strings and numeric types to a nonsensical protocol of your own making.</div></div></div></div></div></blockquote><br class=""></div><div>I concur.&nbsp;</div><div><br class=""></div><div>I am willing to live with the redundancy in the urlString example for the following reasons:</div><div><ul class=""><li class="">Like (other) streams, Swift strings prioritize "append" operations. This is how `+` now works.</li><li class="">If we tie ourselves to mathematical convention, Swift becomes a different language. Consider the Swift assignment operator (`=`), which is definitely not commutative. IMO, Swift uses mathematical conventions. Mathematical conventions do not define Swift.&nbsp;</li><li class="">Prefixing does not place such an undue burden on the user that I think it warrants language modification</li></ul></div><div>-- E</div><div><br class=""></div><br class=""></body></html>