<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">This is the most logical newline stripping behavior in my opinion. It's very easy to think about -- all the lines in-between the triple quotes are the contents of the string. Leading and trailing newlines are easily added if desired by adding extra lines.
<div><br /></div>
<div>To support that model, I also agree with the suggestion that we shouldn't allow multiline string contents on the same line as the opening or closing delimiters. They are multiline strings after all, so I don't see much value in supporting that.</div>
<div><br /></div>
<div>On a separate note, I'd like to bring up the de-indentation behavior I described earlier again. I still feel that having the position of the closing delimiter determine how much whitespace is de-indented is not very natural or intuitive, since I don't think there is any precedent in standard Swift styling to indent a closing delimiter to the same level as its content. Stripping the most common whitespace possible from each line seems to be a much more intuitive and flexible solution in terms of formatting, and it's still compatible with the proposed formatting if that's anyone's preference.</div>
<div><br /></div>
<div>The only functional limitation that I see is that if you can't have leading whitespace in the interpreted string if you actually want that. That doesn't seem like a very important use case to me, but if we think it is important, it could be supported by something like having a backslash in the leading whitespace at the location where it should be preserved from.</div>
<div><br /></div>
<div>If we're set on the proposed behavior, have we considered what happens if the closing delimiter goes beyond the non-whitespace content of the string?</div>
<div><br /></div>
<div>let string = """</div>
<div>    aa</div>
<div>    bb</div>
<div>    cc</div>
<div>     """</div>
<div><br /></div>
<div>Does it strip the non-whitespace characters? Does it strip up to the non-whitespace characters? Does it generate an error?</div>
</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br />
Jarod</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br />
On Apr 12, 2017, 10:41 -0700, Ricardo Parada via swift-evolution <swift-evolution@swift.org>, wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">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="" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">
<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: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;">> 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>
_______________________________________________<br />
swift-evolution mailing list<br />
swift-evolution@swift.org<br />
https://lists.swift.org/mailman/listinfo/swift-evolution<br /></blockquote>
</div>
</body>
</html>