<div dir="ltr">On Wed, Jul 12, 2017 at 5:52 PM, Chris Lattner via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><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">Hello Swift community,<br>
<br>
Context: As part of winding down work on Swift 4, we are considering SE-0182 as a refinement to SE-0168.  We are specifically not opening the floodgates for new proposals just yet, and it is not considered in scope to resyntax all of multi-line string literals.  We’re just discussing this one potential small-scope refinement to an existing Swift 4 feature.<br>
<br>
<br>
The review of &quot;String Newline Escaping&quot; begins now and runs through July 17, 2017. The proposal is available here:<br>
<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0182-newline-escape-in-strings.md" rel="noreferrer" target="_blank">https://github.com/apple/<wbr>swift-evolution/blob/master/<wbr>proposals/0182-newline-escape-<wbr>in-strings.md</a><br>
<br>
Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at<br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br>
or, if you would like to keep your feedback private, directly to the review manager. When replying, please try to keep the proposal link at the top of the message:<br>
<br>
What goes into a review?<br>
<br>
The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:<br>
<br>
        • What is your evaluation of the proposal?<br></blockquote><div><br></div><div>I agree with Adrian&#39;s appraisal of this proposal. Namely, if the core team believes that now is the right time to evaluate new additions to multiline string literal syntax, the addition of `\` as a way to escape the newline is straightforward and has its benefits. However, as voiced by several others, the proposal to add the same feature to single-line string literals should be reconsidered. The specific objections I have in mind, I will detail under the following sections.</div><div> </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">
        • Is the problem being addressed significant enough to warrant a change to Swift?<br></blockquote><div><br></div><div>Potentially. On this point I&#39;m not fully convinced as to how significant the problem is. However, the proposed solution is an additive change that is fairly &quot;obvious&quot; and unlikely to be problematic.</div><div> </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">
        • Does this proposal fit well with the feel and direction of Swift?<br></blockquote><div><br></div><div>As to multiline string literal syntax, yes. However, I&#39;ll outline here my thinking on the issue with single-line string literals.</div><div><br></div><div>The core team rejected this particular feature in the previous proposal for multiline string literals with the admonition that any later addition should address both single-line and multiline string literals. The authors appear to have taken this literally by simply proposing the same feature for both. In previous conversations, it has become apparent that many other possible designs for escaping newlines in both single-line and multiline string literals turn out to be clunky for one or for the other (or for both); _none_ have emerged that seem to work equally well in both situations. Therefore, it is unsurprising that the authors of the current proposal simply propose to use the backslash syntax for both.</div><div><br></div><div>I&#39;ll rationalize my unease with this solution in the following manner:</div><div><br></div><div>1. Generally, `\` is used to escape some other sequence of characters. By that, I mean that the sequence of characters means one thing without the preceding `\` and another with `\`.</div><div>2. In multiline string literals, a naked newline means a newline in the represented string; therefore, it makes good sense that `\` + newline is used to insert a newline in the literal but not in the resulting string.</div><div>3. In single-line string literals, a naked newline is illegal. Hence, `\` + newline is &quot;escaping&quot; a sequence of characters that by itself isn&#39;t even permitted in the literal.</div><div><br></div><div>This results in an asymmetry that is rather odd. In my view, there&#39;s one of two ways to resolve this problem:</div><div><br></div><div>1. Do not add the proposed feature to single-line string literals (Adrian proposes this resolution as well). The basis for such a discrepancy would be: single-line string literals don&#39;t allow newlines; that&#39;s what makes them single-line string literals. The preferred spelling for a single line string represented over multiple lines using single-line string literal syntax would remain:</div><div><br></div><div>```</div><div>let foo = &quot;Hello, &quot;</div><div>          + &quot;world!&quot;</div><div>```</div><div><br></div><div>OR</div><div><br></div><div>2. Do add the proposed feature to single-line string literals. In addition, do add the possibility of using a naked newline character to denote a newline in the resulting string. That is, allow both:</div><div><br></div><div>```</div><div>let foo = &quot;Hello, \</div><div>world!&quot;</div><div><br></div><div>// Hello, world!</div><div><br></div><div>let bar = &quot;Hello,</div><div>world!&quot;</div><div><br></div><div>// Hello,</div><div>// world!</div><div><br></div><div>```</div><div><br></div><div>To my mind, whether (1) or (2) is preferable depends on whether the Swift community believes that the predominant distinction is between string literals that happen to span a single line vs. multiple lines in code (i.e., single-line (string literal) vs. multiline (string literal)) or between literals that represent a single-line string (modulo escaped newline sequences) vs. those that represent multiline strings (i.e., (single-line string) literal vs. (multiline string) literal).</div><div> </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">
        • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br></blockquote><div><br></div><div>JavaScript template literals do have a similar feature. In that language (unless I&#39;m mistaken), the same does not apply to ordinary strings.</div><div>In Python, `\` can be used for line continuations; this is the case both inside strings and outside strings.</div><div>C and Python allow adjacent string literals to be concatenated, which is straightforward and a valid alternative for consideration here.</div><div><br></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">
        • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br></blockquote><div><br></div><div>A quick reading; previously, an in-depth study of the original proposal.</div><div> </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">
More information about the Swift evolution process is available at:<br>
<a href="https://github.com/apple/swift-evolution/blob/master/process.md" rel="noreferrer" target="_blank">https://github.com/apple/<wbr>swift-evolution/blob/master/<wbr>process.md</a><br>
<br>
<br>
Thank you,<br>
<br>
Chris Lattner<br>
Review Manager<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</blockquote></div><br></div></div>