<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I think that there's nothing wrong with two "tools" for the same task in this case. Multiline strings look better in the code and are easier to read and can serve many purposes. By reading different texts from swift dev team I feel like this is something the language was designed with in mind. They're also easier to type and it needn't neccessarily be a string presented to the user.&nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Lets say I want a simple json literal for testing purposes - reading from a file takes much more effort comparing to inserting it directly in the code. Taking out every new line character makes it hard to read, and inserting quotes and pluses every line both needs extra effort and also decreases readability. Adding it as a multiline string would make a perfect solution for this to me.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">There are so many other cases where this could be useful too. I like how python has the """ and I think this would be a good direction to go, although this is true that python uses indentation in a different way, so I think backslashes at the end of each line would be a nice idea - this is still better than concatenating each line with " and +, and would have the least readability impact. Also, it could be treated as a literal and be evaluated at compile time.</div><div><br></div><blockquote type="cite"><div><div dir="ltr">I just checked with -O and without and was surprised to find that `let x = "abc"&nbsp;+ "def"&nbsp;+ "ghi"` wasn't collapsed into a single string literal "abcdefghi" in the generated assembly code. Maybe it's more difficult than it is in some other languages because of operator overloads and different kinds of text literals (strings, extended grapheme clusters, Unicode scalars)?<div><br></div><div>Regardless of the reasons, a separate syntax isn't the right way to achieve this optimization—the compiler should just do it automatically. Like Ricardo, "multi-line string literals" should be reserved for string literals that include the newline characters that are used to break them up in source. The idea of supporting something like the Python example above just provides two ways to do the same thing, which I don't think we really need.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Apr 3, 2017 at 8:18 AM Ricardo Parada 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" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div>I would think that the concatenation would get resolved at runtime, unless the compiler gets smart about it.&nbsp; But either way I do not see it as a problem.&nbsp; The reason is that I don't remember ever worrying about the performance of concatenating a few lines of text. &nbsp;:-)<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Apr 3, 2017, at 11:13 AM, Adrian Zubarev &lt;<a href="mailto:adrian.zubarev@devandartist.com" class="gmail_msg" target="_blank">adrian.zubarev@devandartist.com</a>&gt; wrote:</div><br class="m_4981237499957014445Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div class="m_4981237499957014445bloop_markdown gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><p style="margin:15px 0px" class="gmail_msg">To me a literal a single entity which is solved at compile time. The concatenation is however resolved at runtime if I’m not mistaken here (it might be optimized at compile time but I still would expect a function executed a couple of times at runtime).</p><p style="margin:15px 0px" class="gmail_msg">Please correct me if I’m wrong here.</p><div style="margin:15px 0px" class="gmail_msg"><br class="m_4981237499957014445webkit-block-placeholder gmail_msg"></div></div><div class="m_4981237499957014445bloop_original_html gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><div id="m_4981237499957014445bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px" class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"><div id="m_4981237499957014445bloop_sign_1491232271296286208" class="m_4981237499957014445bloop_sign gmail_msg"><div style="font-family:helvetica,arial;font-size:13px" class="gmail_msg">--&nbsp;<br class="gmail_msg">Adrian Zubarev<br class="gmail_msg">Sent with Airmail</div></div><br class="gmail_msg"><p class="m_4981237499957014445airmail_on gmail_msg" style="margin:15px 0px">Am 3. April 2017 um 17:10:36, Ricardo Parada (<a href="mailto:rparada@mac.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" class="gmail_msg" target="_blank">rparada@mac.com</a>) schrieb:</p><blockquote type="cite" class="m_4981237499957014445clean_bq gmail_msg" style="margin:15px 0px"><span style="margin-top:0px;margin-bottom:0px" class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"></div><div class="gmail_msg">How is that better than this?<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="m_4981237499957014445bloop_markdown gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;background-color:rgb(254,254,254)"><pre style="margin:15px 0px;font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal" class="gmail_msg"><code class="m_4981237499957014445python gmail_msg" style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:0px;margin:0px;padding:0px;word-break:normal;word-wrap:normal">template = "This is the first line.\n" +
            "This is the second line.\n" +
            "This is the third line."
</code></pre><div style="margin:15px 0px" class="gmail_msg"><br class="m_4981237499957014445webkit-block-placeholder gmail_msg"></div></div><div class="m_4981237499957014445bloop_original_html gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;background-color:rgb(254,254,254)"></div><div class="gmail_msg"><blockquote type="cite" style="margin:15px 0px" class="gmail_msg"><div style="margin-top:0px" class="gmail_msg">On Apr 3, 2017, at 10:42 AM, Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_4981237499957014445Apple-interchange-newline gmail_msg"><div style="margin-bottom:0px" class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg">It look prettier without the \n<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It's not laziness.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I want my code to look pretty.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" style="margin:15px 0px" class="gmail_msg"><div style="margin-top:0px" class="gmail_msg">On Apr 3, 2017, at 10:40 AM, Adrian Zubarev &lt;<a href="mailto:adrian.zubarev@devandartist.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" class="gmail_msg" target="_blank">adrian.zubarev@devandartist.com</a>&gt; wrote:</div><br class="m_4981237499957014445Apple-interchange-newline gmail_msg"><div style="margin-bottom:0px" class="gmail_msg"><div class="m_4981237499957014445bloop_markdown gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><p style="margin:15px 0px" class="gmail_msg">What I was trying to say is that by automatically adding a new line character does not provide any benefit except of being lazy to type<span class="m_4981237499957014445Apple-converted-space gmail_msg">&nbsp;</span><code style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(234,234,234);margin:0px 2px;padding:0px 5px;word-break:normal;word-wrap:normal" class="gmail_msg">\n</code>.</p><pre style="margin:15px 0px;font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal" class="gmail_msg"><code class="m_4981237499957014445swift gmail_msg" style="font-family:Menlo,Consolas,'Liberation Mono',Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:0px;margin:0px;padding:0px;word-break:normal;word-wrap:normal">// In your model this would be equivalent
let s1 = "\n\n\n"
let s2 = """
    " // However in my model this is an empty string and should be banned
    "
    """ // That's also an empty string, but it that case it indicates the end of the multi lined string
</code></pre><p style="margin:15px 0px" class="gmail_msg">I dislike the tradeoff of precision for laziness.</p><div style="margin:15px 0px" class="gmail_msg"><br class="m_4981237499957014445webkit-block-placeholder gmail_msg"></div></div><div class="m_4981237499957014445bloop_original_html gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><div id="m_4981237499957014445bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px" class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"><div id="m_4981237499957014445bloop_sign_1491230112191910912" class="m_4981237499957014445bloop_sign gmail_msg"><div style="font-family:helvetica,arial;font-size:13px" class="gmail_msg">--&nbsp;<br class="gmail_msg">Adrian Zubarev<br class="gmail_msg">Sent with Airmail</div></div><br class="gmail_msg"><p class="m_4981237499957014445airmail_on gmail_msg" style="margin:15px 0px">Am 3. April 2017 um 16:29:44, Ricardo Parada (<a href="mailto:rparada@mac.com" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" class="gmail_msg" target="_blank">rparada@mac.com</a>) schrieb:</p><blockquote type="cite" class="m_4981237499957014445clean_bq gmail_msg" style="margin:15px 0px"><div style="margin-top:0px;margin-bottom:0px" class="gmail_msg"><div style="font-family:helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><span style="margin-top:0px;margin-bottom:0px" class="gmail_msg">By the way, the multi-line string should allow \n\n, or as many as you may want to throw in there.&nbsp; I don't see a problem with that.</span></div><span style="margin-top:0px;margin-bottom:0px" class="gmail_msg"><br class="m_4981237499957014445Apple-interchange-newline gmail_msg"></span></div></blockquote></div><div class="m_4981237499957014445bloop_markdown gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><br class="m_4981237499957014445Apple-interchange-newline gmail_msg"></div></div></blockquote></div><br class="gmail_msg"></div></div>_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" style="color:rgb(65,131,196);background-color:inherit;text-decoration:none" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div></div></div></span></blockquote></div><div class="m_4981237499957014445bloop_markdown gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254)"><br class="m_4981237499957014445Apple-interchange-newline gmail_msg"></div></div></blockquote></div><br class="gmail_msg"></div></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>
</div></blockquote></body></html>