<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="">Following this thread it reads to me that SE-0168 being accepted without newline escapes was</div><div class="">regrettable as it gave us more flexibility in formatting “long strings”.</div><div class=""><br class=""></div><div class="">As the core team rejected it on the basis that it was inconsistent with conventional string literals the </div><div class="">obvious thing to do is raise a short micro-proposal that newline escape be introduced into both. This </div><div class="">would also bring them into line with C literals. I’ve drafted a new proposal we could discuss and which</div><div class="">I hope to submit tomorrow as the implementation is trivial if it’s not too late:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/johnno1962c/swift-evolution/blob/master/proposals/0173-newline-escape-in-strings.md" class="">https://github.com/johnno1962c/swift-evolution/blob/master/proposals/0173-newline-escape-in-strings.md</a></div><div class=""><br class=""></div><div class="">For me personally, this would also have the happy side effect of making it possible to reopen the debate</div><div class="">about "should the final newline be stripped by default" as it could now so easily be escaped for those who</div><div class="">like their multiline literals missing a newline on the last line :)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I’ve updated the prototype toolchain to bring it into line with the Core team's decision available here:</div><div class=""><br class=""></div><div class=""><a href="http://johnholdsworth.com/swift-LOCAL-2017-04-22-a-osx.tar.gz" class="">http://johnholdsworth.com/swift-LOCAL-2017-04-22-a-osx.tar.gz</a></div><div class=""><br class=""></div><div class="">(This includes newline escaping on all strings but dutifully strips the last line)</div><div class=""><br class=""></div><div class="">As it looks like this patch might form the basis of the implementation in Swift 4, all testing appreciated.</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift/pull/8813" class="">https://github.com/apple/swift/pull/8813</a></div><div class=""><br class=""></div><div class="">-John</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 23 Apr 2017, at 10:41, 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="">Sure, I can give an example. I'm not going to suggest that it'd win any awards, but:<br class=""><br class="">By restricting multiline literals to begin and end on distinct lines, the core team has established an interesting property. Namely, "literals" are delimited horizontally while """literals""" are delimited vertically.<br class=""><br class="">To enable hard wrapping, permit continuation of literals by apposition of consecutive literals. That is, "Hello, " "world!" would be equivalent to "Hello, world!". This single rule can be applied to either kind of string literal. That is:<br class=""><br class="">let a =<br class=""> "Hello, "<br class=""> "world!"<br class=""><br class="">let b =<br class=""> """<br class=""> Hello, <br class=""> """ """<br class=""> world!<br class=""> """<br class=""><br class="">a == b // true<br class=""><br class="">It certainly permits elided newlines. It is the exact same rule applied to both types of literals. It preserves code indentation and does not require single-line string literals to support code stripping. I leave it to your judgement whether it works "equally well" and/or is "horrible."<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sun, Apr 23, 2017 at 04:13 Brent Royal-Gordon <<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 22, 2017, at 8:12 AM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="m_-1748841490727356249Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Sat, Apr 22, 2017 at 3:38 AM, Brent Royal-Gordon <span dir="ltr" class=""><<a href="mailto:brent@architechies.com" target="_blank" class="">brent@architechies.com</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 21, 2017, at 11:48 AM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class="m_-1748841490727356249m_-9186835439891025487Apple-interchange-newline"><div class=""><span style="font-family:Helvetica;font-size:12px;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;float:none;display:inline!important" class="">This goes to my question to David Hart. Isn't this an argument for a feature to allow breaking a single-line string literal across multiple lines? What makes this a use case for some feature for _multiline_ string literals in particular?</span></div></blockquote><br class=""></div></span><div class="">Well, if you're breaking a string across several lines, you will want indentation stripping too. Are you suggesting we should also bring that feature to single-line string literals with escaped newlines?</div></div></blockquote><div class=""><br class=""></div><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><div style="word-wrap:break-word" class=""><div class="">Could you share an example of such a design? It doesn't have to be something you'd be happy to have in the language; it just needs to fit the following criteria:</div><div class=""><br class=""></div><div class="">* Permits non-significant hard-wrapping in a string literal.</div><div class=""><br class=""></div><div class="">* Works equally well with single and triple string literals.</div><div class=""><br class=""></div><div class="">* Preserves code indentation, but does not require single string literals to do indentation stripping.</div><div class=""><br class=""></div><div class="">* Is not horribly inconvenient.</div></div><div style="word-wrap:break-word" class=""><br class=""><div class="">
<span class="m_-1748841490727356249Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class=""><div style="font-size:12px" class="">-- </div><div style="font-size:12px" class="">Brent Royal-Gordon</div><div style="font-size:12px" class="">Architechies</div></div></span>
</div>
<br class=""></div></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=""></body></html>