<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="">That's an interesting idea! &nbsp;What about """ for escaped strings and ``` for unescaped literal strings?<div class=""><br class=""></div><div class="">The latter is intuitive for me for preformatted text (with JSON et al are), and Swift in fact uses Markdown for doc comments, so we assume some familiarity from the developer.</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 5:21 PM, Travis Tilley via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_default" style="font-family: verdana, sans-serif;">If you're writing a block of github flavored markdown, I can absolutely see someone wanting to write out 3 backticks in a multi-line string literal. ::shrug::</div><div class="gmail_default" style="font-family: verdana, sans-serif;"><br class=""></div><div class="gmail_default" style="font-family: verdana, sans-serif;"><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Dec 11, 2015 at 6:08 PM, Kametrixom Tikara<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:kametrixom@icloud.com" target="_blank" class="">kametrixom@icloud.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="auto" class=""><div class=""></div><div class="">Why don't we just use the back ticks &nbsp;" ` ", making it similar to markup:</div><div class=""><br class=""></div><div class="">let code =</div><div class="">```</div><div class="">main = interact id</div><div class="">```</div><div class=""><br class=""></div><div class="">I believe nobody would ever want to put three back ticks inside a string.</div><div class=""><br class=""></div><div class="">Also I think one doesn't actually want/need interpolation, because every char should be the same in the string as it appears in the code. We can do something like instead (just concat the strings together):</div><div class=""><br class=""></div><div class="">let myString = "Hello!"</div><div class="">let code =</div><div class="">```</div><div class="">main = p "``` + myString + ```"</div><div class="">&nbsp;<span class="Apple-converted-space">&nbsp;</span>where p = putStrLn</div><div class="">```</div><div class=""><br class=""></div><div class="">(Shorter would be to drop the "+" with some compiler magic, but that's meh)</div><div class=""><br class=""></div><div class="">I don't think the use for such literals isn't too common so that it's not necessary to provide string interpolation just for these few cases.</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class="">On 11 Dec 2015, at 18:29, Travis Tilley via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-family: verdana, sans-serif;" class="">My updated thoughts, after some feedback about JSON and escaping, would be to wrap an escaped multi-line literal with triple quotes, and to wrap an unescaped multi-line literal with single quotes... Then, to make the overall syntax consistent, to do the same for single-line strings. In either case, quotes of any kind other than a triple quote would not need to be escaped in a multi-line string literal. So:</div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class="">let foo = """</div><div style="font-family: verdana, sans-serif;" class="">&nbsp;<span class="Apple-converted-space">&nbsp;</span>hell yeah, escapes! \n\n</div><div style="font-family: verdana, sans-serif;" class="">&nbsp;<span class="Apple-converted-space">&nbsp;</span>\(sound) like a "\(animal)"</div><div style="font-family: verdana, sans-serif;" class="">&nbsp;<span class="Apple-converted-space">&nbsp;</span>this is another completely random line</div><div style="font-family: verdana, sans-serif;" class="">"""<br class=""></div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class="">Would have a foo variable containing (note the stripped indentation, as that seems to be the popular request in this thread):</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">hell yeah, escapes!<br class=""><br class="">moo like a "cow"<br class="">this is another completely random line</blockquote><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class="">But if wrapped by ''' then none of the interpolation or escape processing happens (and quotes still don't need to be escaped).</div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class="">Come to think of it, I don't see why a ''' syntax would -have- to be multi-line. No reason why '''/"moo"/"cow"/g''' should be invalid from a technical perspective. (note that swift has no native regex literal, though you can create your own and this triple single-quote syntax might make that less painful)</div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div style="font-family: verdana, sans-serif;" class="">- Travis Tilley</div><div style="font-family: verdana, sans-serif;" class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Dec 11, 2015 at 12:01 PM, John Siracusa via swift-evolution<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class="">Sorry about the lack of a subject on this message originally. I was replying to the email digest and forgot to add one. It should be part of the "multi-line string literals" thread.<div class=""><br class=""></div><div class="">-John<br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Dec 11, 2015 at 11:52 AM, John Siracusa<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:siracusa@gmail.com" target="_blank" class="">siracusa@gmail.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class=""><span class=""><div class=""><br class=""></div><div class="">Chris Lattner wrote:</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">When introducing a feature like this, I think it would be useful to survey a range of popular languages (and yes, even perl ;-) to understand what facilities they provide and why (i.e. what problems they are solving) and synthesize a good swift design that can solve the same problems with a hopefully simple approach.</blockquote><div class=""><br class=""></div></span><span class=""><div class="">Travis Tilley wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">​Perl and Erlang are unique in that valid code in either language looks essentially like line noise. I'd rather take inspiration from languages like ruby, python, and elixir.​</blockquote><div class=""><br class=""></div></span><div class=""><div class="">Jokes aside, the ability to choose delimiters for strings and other language constructs that surround some value is a huge boon to code readability.</div><div class=""><br class=""></div><div class="">For example, RegExp literals in JavaScript:</div><div class=""><br class=""></div><div class="">var regex = /^\/usr\/local\//; // gross</div><div class=""><br class=""></div><div class="">An even simpler example, which applies to many languages: a string literal that contains all of your possible string delimiters within it. This is not an exotic thing in English.</div><div class=""><br class=""></div><div class="">message = "\"I don't like this,\" she said."; // nope</div><div class="">message = '"I don\'t like this," she said.'; &nbsp;// still nope</div><div class=""><br class=""></div><div class="">Then, of course, there's your escape character itself:</div><div class=""><br class=""></div><div class="">escapes = "Some escapes: <a href="smb://n" class="">\\n</a>, <a href="smb://t" class="">\\t</a>, <a href="smb://a" class="">\\a</a>"; // sigh</div><div class=""><br class=""></div><div class="">There are many time-tested solutions to these syntactic/cosmetic problems.&nbsp;</div><div class=""><br class=""></div><div class="">* Different delimiters with different interpolation rules (e.g., single quotes not honoring any backslash escapes and not doing variable interpolation)</div><div class=""><br class=""></div><div class="">* Matched-pair delimiters that don't require anything to be escaped as long as the delimiters are absent or matched within the string. (These alone solve a huge range of problems.)</div><div class=""><br class=""></div><div class="">* Heredocs for long literals where you get to pick the end token.</div><div class=""><br class=""></div><div class="">* Heredocs modified by delimiters around the end token to control interpolation within the long literal.</div><div class=""><br class=""></div><div class="">Which language looks like line noise now?</div><div class=""><br class=""></div><div class=""><span style="white-space: pre-wrap;" class="">        </span>$messasge = q("I can't believe how nice this is," she said (quietly).);</div><div class=""><br class=""></div><div class=""><span style="white-space: pre-wrap;" class="">        </span>$regex = qr(^/usr/local/);</div><div class=""><br class=""></div><div class=""><span style="white-space: pre-wrap;" class="">        </span>$escapes = 'Some escapes: \n, \t, \a';</div><div class=""><br class=""></div><div class="">My take: once you use a language where you pretty much never have to backslash-escape a character you can easily type to get it into a string, it's really hard to go back.&nbsp;</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">-John</div></font></span></div><div class=""><br class=""></div></div></blockquote></div><br class=""></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=qZpXMk9vJDqToeTsZCIqiZt6H6WbJ-2F4cetScK5CvwczCEWW-2BI3OMLZu7GD-2BgsYQ9NDqs118P1PwLmtiYZehKrBEZSFtUW8bnydcWaNaL-2FFC60nd-2FwOFOKEDsa8QWe-2BCND3Iayy4iVeG1kfuxfMx11dg1-2BTBo1Kp15xhSRjWi77R8wd4wuyrLaKAAyNpujf9P-2FoX0PEsi2JTEGlePF6sVxm-2Bg9WF34lkwKUQ3uLLUckA-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span class="Apple-converted-space">&nbsp;</span><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class=""></blockquote></div><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=UMghxGHOvTEcVGG3PKHzuJe-2F1jwKPcDcSNH0SiRhP17Nz0QJo2F3Ck18os9XjPTy-2Bfr5qI-2B7tv-2FPGqZLlz6fLEx9iUzluJTEbWvqGiAXpk9lBT1j6EETYupvoD9-2B5DG2MuShMNtiFQqFL3wqaxDhiHiv5zbjbe0K4cfqQNYsm3N6pwxs2Wdjk-2FTk9SFa6wbLFgj0gHfa-2BbfjxjPLxQh0SVaMoL2jOuyuVoKzUyq878k-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div></div></div></blockquote></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=OtwgWwWn2mvmck2XIGZZg64wEmoo4f4ILYe4SqMqwHqT7FehBahIb-2Ba-2FL69Nfb9j3qxPlmBWeaRG6q-2BgzM1ySzOGZZNrc4lq68THTTezob5X90-2Bdnw6tSDSvTDEwcl58BD5Q0yb43dMkkfop-2FGFMlcXeSLu9lzQ8skD8IBfKJr1-2BCaz2FXEOwg7lke5V7dvciGiV1c5t2Wy9eKtasaffT89CNUZVyNU5VggNTfH46pU-3D" alt="" width="1" height="1" border="0" style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></body></html>