<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=""><div class="">Okay, so maybe we should not strip the trailing newline.</div><div class=""><br class=""></div><div class="">The xml concatenation example in Brent's revised proposal assumes the literal includes a trailing newline.</div><div class=""><br class=""></div><div class=""><div class="">Also, if you do this in Swift:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span style="font-size: 12px;" class="">print("Line1\n")</span></font></div><div class=""><font face="Monaco" class=""><span style="font-size: 12px;" class="">print("Line 2")</span></font></div><div class=""><br class=""></div><div class="">It seems to strip trailing newlines. So the above actually outputs this with no empty line in between them:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span style="font-size: 12px;" class="">Line 1</span></font></div><div class=""><font face="Monaco" class=""><span style="font-size: 12px;" class="">Line 2</span></font></div><div class=""><br class=""></div><div class="">Conclusion: I think it is best to include the trailing newline. :-)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 12, 2017, at 1:52 PM, Adrian Zubarev <<a href="mailto:adrian.zubarev@devandartist.com" class="">adrian.zubarev@devandartist.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="bloop_markdown" 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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);"><p style="margin: 15px 0px; -webkit-margin-before: 0px;" class="">Actually this would be inconsistent. The lines in between the delimiters should always add an implicit new line if not told otherwise with a backslash. If that wouldn’t be the case than you won’t have any precision in the last line you have there.</p><p style="margin: 15px 0px;" class="">Assume you want to concatenate this string:</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=""><code class="swift" 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; -webkit-margin-before: 0px;">foo
bar baz
</code></pre><p style="margin: 15px 0px;" class="">To do so you’d need extra spaces in your<span class="Apple-converted-space"> </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; -webkit-margin-before: 0px;" class="">" baz"</code><span class="Apple-converted-space"> </span>string, because of the inconsistency. However the constant version I’m suggesting is more precise.</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=""><code class="swift" 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; -webkit-margin-before: 0px;">let myString = """
foo
bar \
"""
print(myString + "baz")
</code></pre><p style="margin: 15px 0px;" class="">The last implicit new line which one would need to escape is a model artifact, but it’s consistent that way.</p><p style="margin: 15px 0px;" class="">The extra new line one would ever need to add manually would be only at the top of a multi-line string.</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=""><code class="swift" 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; -webkit-margin-before: 0px;">// v1:
"""
foo
bar\
"""
// v2:
"""
\n\
foo
bar\
"""
// v3:
"""
\nfoo
bar\
"""
</code></pre><div style="margin: 15px 0px;" class=""><br class="webkit-block-placeholder"></div></div><div class="bloop_original_html" 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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);"><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><br class=""><div id="bloop_sign_1492019016117445888" class="bloop_sign"><div style="font-family: helvetica, arial; font-size: 13px;" class="">-- <br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div><br class=""><p class="airmail_on" style="margin: 15px 0px;">Am 12. April 2017 um 19:41:14, Ricardo Parada via swift-evolution (<a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">swift-evolution@swift.org</a>) schrieb:</p><blockquote type="cite" class="clean_bq" style="margin: 15px 0px;"><span style="margin-top: 0px; margin-bottom: 0px;" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""></div><div class="">Hi all,<div class=""><br class=""></div><div class="">I agree as well, I think we should make optimize for the most common case of multi-line strings. A rule that says strip the first leading newline as well as the trailing newline. So it's almost back to where Brent started with the addition of removing the trailing newline. <div class=""><br class=""></div><div class="">Borrowing Adrian's example, I could just have this:<div class=""><pre class="" 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;"><code class="swift" 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; -webkit-margin-before: 0px;">
let myReallyLongXMLConstantName = """
<?xml version="1.0"?>
<catalog>
<book id="bk101" empty="">
<author>John Doe</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
</book>
</catalog>
""" </code></pre><div class="">If somebody wants the last line to include a newline at the end, they can just add a <font face="Monaco" class="" style="font-size: 12px;">\n</font> at the end or an empty line.</div><div class=""><br class=""></div><div class="">So if I do this:</div><div class=""><pre class="" 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;"><code class="swift" 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; -webkit-margin-before: 0px;">print(myReallyLongXMLConstantName)
print("Text right below")</code></pre><div class="">It would output this:</div></div><div class=""><br class=""></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <?xml version="1.0"?></font></div><div class=""><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <catalog></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <book id="bk101" empty=""></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <author>John Doe</author></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <title>XML Developer's Guide</title></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <genre>Computer</genre></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <price>44.95</price></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> </book></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> </catalog></font></div></div><div class=""><font face="Monaco" class="" style="font-size: 12px;">Test right below</font></div><div class=""><br class=""></div><div class="">Without removing the trailing newline then it would print like this:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <?xml version="1.0"?></font></div><div class=""><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <catalog></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <book id="bk101" empty=""></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <author>John Doe</author></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <title>XML Developer's Guide</title></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <genre>Computer</genre></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> <price>44.95</price></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> </book></font></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"> </catalog></font></div></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"><br class=""></font></div><div class=""><div class=""><font face="Monaco" class="" style="font-size: 12px;">Test right below</font></div></div></div><div class=""><font face="Monaco" class="" style="font-size: 12px;"><br class=""></font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class="" style="margin: 15px 0px;"><div class="" style="margin-top: 0px;">On Apr 12, 2017, at 12:48 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="" style="margin-bottom: 0px;">Agree. I prefer the new rules over the old, but considering common use cases, stripping the leading and trailing newline makes for a more pleasant experience than not stripping either of them.<br class=""><br class="">I think that is generally worth prioritizing over a simpler algorithm or even accommodating more styles. Moreover, a user who wants a trailing or leading newline merely types an extra one if there is newline stripping, so no use cases are made difficult, only a very common one is made more ergonomic.<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Apr 12, 2017 at 09:52 Thorsten Seitz via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">> Am 12.04.2017 um 15:40 schrieb Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none; margin-top: 0px;">swift-evolution@swift.org</a>>:<br class="gmail_msg">><br class="gmail_msg">> Hey folks,<br class="gmail_msg">><br class="gmail_msg">><br class="gmail_msg">> We've revised the proposal again. The main difference: You no longer need an initial newline to enable indentation stripping, and stripping no longer removes that newline even if it is present. (Adrian Zubarev and I believe some others argued for this.) We<br class="gmail_msg"><br class="gmail_msg">Hmm, not sure if I like these changes. I expect that almost all strings won't begin with a newline and a majority won’t end with a newline. The new design would require a leading backslash almost all the time and a trailing backslash often, which is ugly:<br class="gmail_msg"><br class="gmail_msg">let mystring = "““\<br class="gmail_msg"> text text<br class="gmail_msg"> text text\<br class="gmail_msg"> "““<br class="gmail_msg"><br class="gmail_msg">-Thorsten<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">> disagreed with this at first, but it made more sense as we thought about it more. There are a few things we like about it:<br class="gmail_msg">><br class="gmail_msg">> 1. The rules and algorithm are simpler.<br class="gmail_msg">> 2. It accommodates more coding styles.<br class="gmail_msg">> 3. Every non-escaped newline in the literal now creates a corresponding newline in the resulting string.<br class="gmail_msg">> 4. it's easy to get the old behavior back by backslashing the leading newline.<br class="gmail_msg">><br class="gmail_msg">> Unfortunately, I think this precludes stripping the trailing newline by default, but I think this is ultimately a simpler and better approach than the previous draft.<br class="gmail_msg">><br class="gmail_msg">> Other changes:<br class="gmail_msg">><br class="gmail_msg">> * We realized we needed to make closing delimiter matching a little more complicated if we wanted to allow one or two adjacent double-quote characters that were part of the literal's contents. Oops.<br class="gmail_msg">> * Tabs aren't actually allowed in ordinary string literals, so we now explicitly mention that as a difference between the two types.<br class="gmail_msg">> * We wrote some tests for the prototype (though they haven't been updated for this new version yet).<br class="gmail_msg">> * There were some other wording changes, particularly in the indentation stripping rationale, but nothing that affects the actual design.<br class="gmail_msg">><br class="gmail_msg">> I understand John is working on a new version of his toolchain so people can play with the prototype. We hope to have that ready for you all soon.<br class="gmail_msg">><br class="gmail_msg">> Let us know what you think of the revisions!<br class="gmail_msg">><br class="gmail_msg">> --<br class="gmail_msg">> Brent Royal-Gordon<br class="gmail_msg">> Architechies<br class="gmail_msg">><br class="gmail_msg">> _______________________________________________<br class="gmail_msg">> swift-evolution mailing list<br class="gmail_msg">><span class="Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a><br class="gmail_msg">><span class="Apple-converted-space"> </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"><br class="gmail_msg">_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">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" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg" style="margin-bottom: 0px;"></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></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></div></span></blockquote></div><div class="bloop_markdown" 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; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);"></div></div></blockquote></div><br class=""></div></div></body></html>