<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}

h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}

h1 {
        color: #000000;
        font-size: 28pt;
}

h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}

h3 {
        font-size: 18px;
}

h4 {
        font-size: 16px;
}

h5 {
        font-size: 14px;
}

h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}

hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
    display: inherit;
}

p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}

a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}

#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}

button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}

code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}

code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}

pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}

pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}

#ws { background-color: #f8f8f8; }


.bloop_markdown table {
border-collapse: collapse;  
font-family: Helvetica, arial, freesans, clean, sans-serif;  
color: rgb(51, 51, 51);  
font-size: 15px; line-height: 25px;
padding: 0; }

.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
     
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }

.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }

.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }

.bloop_markdown blockquote{
  border-left: 4px solid #dddddd;
  padding: 0 15px;
  color: #777777; }
  blockquote > :first-child {
    margin-top: 0; }
  blockquote > :last-child {
    margin-bottom: 0; }

code, pre, #ws, #message {
    word-break: normal;
    word-wrap: normal;
}

hr {
    display: inherit;
}

.bloop_markdown :first-child {
    -webkit-margin-before: 0;
}

code, pre, #ws, #message {
    font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}


.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>I’ve never thought about allowing hard wrapping from single quoted string literals until it come up during the latest discussion.</p>

<p>At first glance I don’t have anything against it. I wouldn’t put comments into the mix for now, to keep things simple. (I’ve already asked about comments, but the community rejected the idea _for now_.)</p>

<p>What was the exact use case for hard wrapping for the single quoted literals again? (Again I’m not against it.) Actually I believe I pitched a very similar design in the discussion thread (not during the review). </p>

<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1492957351171724032" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">--&nbsp;<br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 23. April 2017 um 13:14:35, Pyry Jahkola via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div dir="auto"><div></div><div>



<title></title>


<div>
<div>Hmm, I can see that Wux already replied to this question but
let me give another more or less obvious answer which I believe has
come up in a shape or another already:</div>
<div><br></div>
<div>Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;
wrote:</div>
<div><br></div>
<blockquote type="cite">
<div>
<div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="">No, I am suggesting that whatever design is used for
escaped newlines, if at all possible it should be equally apt for
"strings" and """strings""" such that it will not require
indentation stripping.</div>
</div>
</div>
</div>
</div>
</blockquote>
<br class=""></div>
<div>Could you share an example of such a design?</div>
</div>
</blockquote>
<div><br></div>
<div>One way to achieve the criteria below for both singly and
triply quoted strings would be to borrow the <i>repeated opening
quote</i> syntax (from earlier discussions) for singly quoted
strings:</div>
<div><br></div>
<div>&nbsp; &nbsp; <b>let s1 = "abc\</b></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<b>"def\n\</b></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>"ghi
\</b></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<b>"xyz"</b></div>
<div><b>&nbsp; &nbsp;&nbsp;</b><span style="background-color: rgba(255, 255, 255, 0);">assert(s1
==&nbsp;<b>"abcdef\nghi xyz"</b>)</span></div>
<div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;
&nbsp;&nbsp;</span></div>
<div>&nbsp; &nbsp; <b>let s2 = "abc\</b></div>
<div><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;"def\n\</b></div>
<div>&nbsp; &nbsp; /* Leading white space, */ <b>"ghi \</b></div>
<div>&nbsp; &nbsp; // as well as comments</div>
<div>&nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; // and empty lines in between are</div>
<div>&nbsp; &nbsp; // insignificant when it comes to singly</div>
<div>&nbsp; &nbsp; // quoted literals.</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "<b>xyz"</b></div>
<div><b>&nbsp; &nbsp;&nbsp;</b><span style="background-color: rgba(255, 255, 255, 0);">assert(s2 ==
s1)</span></div>
<div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp;
&nbsp;&nbsp;</span></div>
<div>&nbsp; &nbsp; <b>let s3 = """</b></div>
<div><b>&nbsp; &nbsp; &nbsp; &nbsp; abc\</b></div>
<div><b>&nbsp; &nbsp; &nbsp; &nbsp; def</b></div>
<div><b>&nbsp; &nbsp; &nbsp; &nbsp; ghi \</b></div>
<div><b>&nbsp; &nbsp; &nbsp; &nbsp; xyz</b></div>
<div><b>&nbsp; &nbsp; &nbsp; &nbsp; """</b></div>
<div>&nbsp; &nbsp; <span style="background-color: rgba(255, 255, 255, 0);">assert(s3 ==
s1)</span></div>
<div>
<div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div>
<div><span style="background-color: rgba(255, 255, 255, 0);">The
criteria:</span></div>
<div><br></div>
</div>
<blockquote type="cite">
<div>* Permits non-significant hard-wrapping in a string
literal.</div>
</blockquote>
<div><br></div>
<div>✅ The string continues from the position of the backslash,
with no extra space or line break inserted.</div>
<br>
<blockquote type="cite">
<div>
<div>* Works equally well with single and triple string
literals.</div>
</div>
</blockquote>
<div><br></div>
<div>✅ <span style="background-color: rgba(255, 255, 255, 0);">In
both cases, a trailing `\` has the same meaning. In singly quoted
strings, the only way to insert a newline is by quoting (`\n`), as
it always was.</span></div>
<br>
<blockquote type="cite">
<div>
<div>* Preserves code indentation, but does not require single
string literals to do indentation stripping.</div>
</div>
</blockquote>
<div><br></div>
<div>✅ The indentation is just more explicit with singly quoted
string literals.</div>
<br>
<blockquote type="cite">
<div>
<div>* Is not horribly inconvenient.</div>
</div>
</blockquote>
<br>
<div>🤷‍♂️ Depends who you ask, I guess, but I think not horrible.
And, after all, the programmer is free to choose between two
quoting styles with different trade offs.</div>
<div><br></div>
<div>* * *</div>
<div><br></div>
<div>One thing that remains to be defined is whether trailing space
is allowed (and ignored) after the backslash or not (and thus an
error). I initially thought it's best to make into a compiler
error, just like the indenting white space of the triple quoted
string literals.</div>
<div><br></div>
<div>OTOH, we could also allow inline comments after the
backslash:</div>
<div><br></div>
<div>&nbsp; &nbsp; let whyNot = "this, \</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "that, \&nbsp;<b>// &lt;- Oxford
comma</b></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "and stuff"</div>
<div>&nbsp; &nbsp; assert(whyNot == "this, that, and stuff")</div>
<div>&nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; let list = """</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; - this,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; - that,\n\<b>// comment using
"Adrian's \n\"</b></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; - and stuff</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; """</div>
<div>&nbsp; &nbsp; assert(list == "- this,\n- that,\n- and
stuff")</div>
<div><br></div>
<div>[Nit: If comments after the backslash were allowed, we'd need
to <b>either</b> require a space after the backslash (e.g. `\ //`),
<b>or else</b> accept <span style="background-color: rgba(255, 255, 255, 0);">as string continuation
/ comment start markers</span> both `\//` (until newline) and `\/*`
(until `*/`), as seen in the latter example above.]</div>
<div><br></div>
<div>I find this design — with or without comments — would
naturally allow the programmer to choose between precision (singly
quoted) and convenience/legibility (triply quoted). And of course
it would allow breaking long string literals to multiple lines in a
consistent way, which, for triply quoted strings, is also lighter
than just concatenating with `+`.</div>
<div><br></div>
<div>— Pyry</div>
<div><br></div>
<div><span style="background-color: rgba(255, 255, 255, 0);">PS. I
also slightly regret that SE-0168 ended up stripping the trailing
newline, because multiline strings seem to compose (concatenate)
better with a trailing newline there by default. But I understand
if the inconvenience of `print(str, terminator: "")` weighed more
than the other option.</span></div>
</div>


_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>