<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="">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 style="margin-top: 15px; margin-bottom: 15px; 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); 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; 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" style="font-size: 12px;" class="">\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 style="margin-top: 15px; margin-bottom: 15px; 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); 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; 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" style="font-size: 12px;" class=""> <?xml version="1.0"?></font></div><div class=""><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <catalog></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <book id="bk101" empty=""></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <author>John Doe</author></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <title>XML Developer's Guide</title></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <genre>Computer</genre></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <price>44.95</price></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> </book></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> </catalog></font></div></div><div class=""><font face="Monaco" style="font-size: 12px;" class="">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" style="font-size: 12px;" class=""> <?xml version="1.0"?></font></div><div class=""><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <catalog></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <book id="bk101" empty=""></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <author>John Doe</author></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <title>XML Developer's Guide</title></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <genre>Computer</genre></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> <price>44.95</price></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> </book></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""> </catalog></font></div></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""><br class=""></font></div><div class=""><div class=""><font face="Monaco" style="font-size: 12px;" class="">Test right below</font></div></div></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""><br class=""></font></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 12:48 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">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="">swift-evolution@swift.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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">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">
> <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">
<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">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>
_______________________________________________<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></blockquote></div><br class=""></div></div></div></div></body></html>