<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="">I think I’d rather treat the multiline literal as a fenced block.</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">let text =</font></div><div class=""><font face="Menlo" class=""> ""</font><span style="font-family: Menlo;" class="">"</span></div><div class=""><font face="Menlo" class=""> The position of the first </font><span style="font-family: Menlo;" class="">"</span><font face="Menlo" class=""> is where the indentation is considered the left-edge.</font></div><div class=""><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class=""> This line is indented four spaces.</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> If I want a newline at the end of the string, I simply put one.</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span></div><div class=""><br class=""></div><div class="">This creates very easy rules to understand:</div><div class=""><br class=""></div><div class=""><ol class="MailOutline"><li class="">The position of the opening <font face="Menlo" class="">""</font><span style="font-family: Menlo;" class="">"</span> dictates the left-edge for indentation purposes.</li><li class="">It’s invalid to have any text on the lines that contain the start and stop tokens: <font face="Menlo" class="">""</font><span style="font-family: Menlo;" class="">"</span></li><li class="">The start and stop tokens must be left-edge aligned.</li><li class="">Text cannot be in a column that preceding the column the tokens start on, unless it is only whitespace.</li></ol><div class=""><br class=""></div></div><div class="">More examples:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">let text =</font></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><font face="Menlo" class=""> Invalid: This is not allowed.</font></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span></div></div><div class=""><span style="font-family: Menlo;" class=""><br class=""></span></div><div class=""><div class=""><font face="Menlo" class="">let text = </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><font face="Menlo" class=""> Invalid; edges are not aligned.</font></div><div class=""><span style="font-family: Menlo;" class=""> </span></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span></div></div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">let text = </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class=""> Invalid: Text cannot start before the </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class=""> tokens.</span></div><div class=""><span style="font-family: Menlo;" class=""> </span></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span></div></div><div class=""><span style="font-family: Menlo;" class=""><br class=""></span></div><div class=""><div class=""><div class=""><font face="Menlo" class="">let text = </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class=""> This is ok.</font></div><div class=""><span style="font-family: Menlo;" class=""> </span></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span></div></div></div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font face="Menlo" class="">let text = </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class=""> Escaped characters are interpreted as normal: \n\n</font></div><div class=""><font face="Menlo" class=""> There will be two newlines above this string when rendered.</font></div><div class=""><span style="font-family: Menlo;" class=""> </span></div><div class=""><font face="Menlo" class=""> </font><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span><span style="font-family: Menlo;" class="">"</span></div></div></div><div class=""><span style="font-family: Menlo;" class=""><br class=""></span></div><div class="">-David</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 10, 2015, at 10:33 PM, Travis Tilley 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=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:verdana,sans-serif">I had been operating on the assumption that a leading blank line would be stripped if present, since the syntax in code would look much cleaner, but a trailing line would not since it would likely be intentional. I guess that's another detail that would need to be fleshed out if we decide to go with triple quote syntax (which, at this point, isn't a given... chris lattner brings up some very good points that might require more involved, potentially heredoc-like, syntax to solve).</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">Your fourth rule, however, I don't agree with at all. It should be obvious from where you place the final quotes whether or not the string includes a trailing newline. Just like in ruby, I believe in and value the principle of least surprize. </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_default" style="font-family:verdana,sans-serif">- Travis Tilley</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 1:04 AM, Jason Dusek <span dir="ltr" class=""><<a href="mailto:jason.dusek@gmail.com" target="_blank" class="">jason.dusek@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class=""><span class=""><p style="margin:1.2em 0px!important" class="">On Thu, 10 Dec 2015 at 21:45, Travis Tilley via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</p><div style="margin: 1.2em 0px !important;" class=""><br class="webkit-block-placeholder"></div><div class=""><div class=""><br class="webkit-block-placeholder"></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div style="font-family:verdana,sans-serif" class="">The ruby <<- heredoc syntax, unlike the << heredoc syntax, will strip indentation if necessary. Technically, it searches for the "least indented line" in the whole string, and removes exactly that amount from each line. So yes, the indentation problem -is- solved in ruby (though it might break entirely if you have empty lines, since the least indented line has no indentation).</div></div></blockquote><div class=""><br class="webkit-block-placeholder"></div></div><div style="margin: 1.2em 0px !important;" class=""><br class="webkit-block-placeholder"></div>
</span><p style="margin:1.2em 0px!important" class="">To my mind, the rules should be:</p>
<ol style="margin:1.2em 0px;padding-left:2em" class="">
<li style="margin:0.5em 0px" class="">The indentation level is set from the least indented line that is not the first line and is not empty.</li>
<li style="margin:0.5em 0px" class="">A leading empty line is removed.</li>
<li style="margin:0.5em 0px" class="">The leading line, if there is any text in it, is not subject to de-indentation.</li>
</ol><p style="margin:1.2em 0px!important" class="">I genuinely believe these three rules taken together address all the errors and infelicities to which triple quotes and HEREDOCs subject us. Here are some examples:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)" class="">text = <span style="color:rgb(221,17,68)" class="">"""
Some
Features
Are
Discussed
"""</span>
<span style="color:rgb(153,153,136);font-style:italic" class=""># From (1): The indentation is taken from the third line below `text`, so it's 2.</span>
<span style="color:rgb(153,153,136);font-style:italic" class=""># From (2): First line is: "\n" so it is removed.</span>
<span style="color:rgb(153,153,136);font-style:italic" class=""># From (3): No effect.</span>
text = <span style="color:rgb(221,17,68)" class="">""" Some
Features
Are
Discussed
"""</span>
<span style="color:rgb(153,153,136);font-style:italic" class=""># From (1): The indentation is taken again from the line reading "Features". Here it is 10.</span>
<span style="color:rgb(153,153,136);font-style:italic" class=""># From (2): No effect.</span>
<span style="color:rgb(153,153,136);font-style:italic" class=""># From (3): The leading whitespace in ` Some` is preserved.</span>
</code></pre><p style="margin:1.2em 0px!important" class="">Do you all think these rules pass muster?</p><p style="margin:1.2em 0px!important" class="">A fourth rule — one which seems advisable but also less necessary than the others — is that a string constructed in this way always ends with a newline. It is a rule that perhaps leads to surprises and inconsistencies.</p><p style="margin:1.2em 0px!important" class="">Best Regards,</p><p style="margin:1.2em 0px!important" class="">Jason</p>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfcXVvdGUiPjxkaXYgZGlyPSJsdHIiPk9uIFRodSwgMTAgRGVjIDIw
MTUgYXQgMjE6NDUsIFRyYXZpcyBUaWxsZXkgdmlhIHN3aWZ0LWV2b2x1dGlvbiAmbHQ7PGEgaHJl
Zj0ibWFpbHRvOnN3aWZ0LWV2b2x1dGlvbkBzd2lmdC5vcmciIHRhcmdldD0iX2JsYW5rIj5zd2lm
dC1ldm9sdXRpb25Ac3dpZnQub3JnPC9hPiZndDsgd3JvdGU6PGJyPjwvZGl2PjxibG9ja3F1b3Rl
IGNsYXNzPSJnbWFpbF9xdW90ZSIgc3R5bGU9Im1hcmdpbjowIDAgMCAuOGV4O2JvcmRlci1sZWZ0
OjFweCAjY2NjIHNvbGlkO3BhZGRpbmctbGVmdDoxZXgiPjxkaXYgZGly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C9kaXY+PGRpdj4m
bmJzcDsgJm5ic3A7ICZuYnNwOyAmbmJzcDsgJm5ic3A7ICZuYnNwOyBEaXNjdXNzZWQ8L2Rpdj48
ZGl2PiIiIjwvZGl2PjxkaXY+IyBGcm9tICgxKTogVGhlIGluZGVudGF0aW9uIGlzIHRha2VuIGFn
YWluIGZyb20gdGhlIGxpbmUgcmVhZGluZyAiRmVhdHVyZXMiLiBIZXJlIGl0IGlzIDEwLjwvZGl2
PjxkaXY+IyBGcm9tICgyKTogTm8gZWZmZWN0LjwvZGl2PjxkaXY+IyBGcm9tICgzKTogVGhlIGxl
YWRpbmcgd2hpdGVzcGFjZSBpbiBgICZuYnNwO1NvbWVgIGlzIHByZXNlcnZlZC48L2Rpdj48ZGl2
PmBgYDwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+RG8geW91IGFsbCB0aGluayB0aGVzZSBydWxl
cyBwYXNzIG11c3Rlcj88L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PkEgZm91cnRoIHJ1bGUgLS0g
b25lIHdoaWNoIHNlZW1zIGFkdmlzYWJsZSBidXQgYWxzbyBsZXNzIG5lY2Vzc2FyeSB0aGFuIHRo
ZSBvdGhlcnMgLS0gaXMgdGhhdCBhIHN0cmluZyBjb25zdHJ1Y3RlZCBpbiB0aGlzIHdheSBhbHdh
eXMgZW5kcyB3aXRoIGEgbmV3bGluZS4gSXQgaXMgYSBydWxlIHRoYXQgcGVyaGFwcyBsZWFkcyB0
byBzdXJwcmlzZXMgYW5kIGluY29uc2lzdGVuY2llcy48L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2
PkJlc3QgUmVnYXJkcyw8L2Rpdj48ZGl2PiZuYnNwOyBKYXNvbjwvZGl2PjwvZGl2Pg==" style="min-height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class=""></div></div></div></blockquote></div>
</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43pXkLx-2B36P-2BPNJufHeY0dgcG1a2qgARtkscK9573-2BVmscXS6V3ezn6lHY6jcm8BxOUPbfYDio5rcCppfEuXGkEsrzLR6GmLgb0I5Ec1vPMr3A4xzzM5-2BI-2B56EE40EW3gl9YjDl954m3x3PRsEwmEVdaSMDBSm-2FiK-2FFDFEIKBoekJfwjNYG74AQLFiOOhyHclaQ-3D-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<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>