<div dir="ltr"><div class="gmail_extra">Actually many text editors will cascade syntax highlighting on purpose, to make it more visually obvious that you have forgotten a quote. Pretty much every tmbundle supports cascading, including the one for Swift.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">This is why text editors have autopair.</div><div class="gmail_extra"><br></div><div class="gmail_extra">- Alex</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 14, 2015 at 8:40 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Dec 11, 2015, at 11:25 PM, Travis Tilley via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">You'd have to ask Chris Latter and Dmitri Gribenko, who are responsible for the lines in Lexer.cpp that prevent it: </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><table style="border-collapse:collapse;border-spacing:0px;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:13px;line-height:18.2px"><tbody><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td rowspan="3" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;float:right;background-color:transparent" target="_blank"><br>22610d5</a><img alt="@lattner" height="32" src="https://avatars0.githubusercontent.com/u/15152540?v=3&s=64" width="32" style="border:0px;display:inline-block;overflow:hidden;line-height:1;vertical-align:middle;border-radius:3px;float:left;margin-right:5px"><span style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" title="substantially improve error recovery for erroneous character and string literals.
Before we'd emit multiple diagnostics and confuse the lexer in some really common
cases (e.g. malformed escapes).
Swift SVN r5242" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent" target="_blank">substantially improve error recovery for erroneous character and stri…</a></span><div style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/lattner" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent" target="_blank">lattner</a> authored on May 20, 2013</div></td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1147</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"></td></tr><tr><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1148</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"> <span style="color:rgb(150,152,150)">// String literals cannot have \n or \r in them.</span></td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td rowspan="2" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/3bee330e5068eb6ed4e825ff77b9e7615758eb47" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;float:right;background-color:transparent" target="_blank">3bee330</a><img alt="@gribozavr" height="32" src="https://avatars1.githubusercontent.com/u/1120569?v=3&s=64" width="32" style="border:0px;display:inline-block;overflow:hidden;line-height:1;vertical-align:middle;border-radius:3px;float:left;margin-right:5px"><span style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/3bee330e5068eb6ed4e825ff77b9e7615758eb47" title="Lexer: don't inf loop on an unterminated string literal near EOF
Swift SVN r7474" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent" target="_blank">Lexer: don't inf loop on an unterminated string literal near EOF</a></span><div style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/gribozavr" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent" target="_blank">gribozavr</a> authored on Aug 22, 2013</div></td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1149</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"> <span style="color:rgb(167,29,93)">if</span> (*CurPtr == <span style="color:rgb(24,54,145)"><span>'</span><span>\r</span><span>'</span></span> || *CurPtr == <span style="color:rgb(24,54,145)"><span>'</span><span>\n</span><span>'</span></span> || CurPtr == BufferEnd) {</td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td rowspan="4" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;float:right;background-color:transparent" target="_blank">22610d5</a><img alt="@lattner" height="32" src="https://avatars0.githubusercontent.com/u/15152540?v=3&s=64" width="32" style="border:0px;display:inline-block;overflow:hidden;line-height:1;vertical-align:middle;border-radius:3px;float:left;margin-right:5px"><span style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf" title="substantially improve error recovery for erroneous character and string literals.
Before we'd emit multiple diagnostics and confuse the lexer in some really common
cases (e.g. malformed escapes).
Swift SVN r5242" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent" target="_blank">substantially improve error recovery for erroneous character and stri…</a></span><div style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/lattner" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent" target="_blank">lattner</a> authored on May 20, 2013</div></td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1150</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"> <span style="color:rgb(0,134,179)">diagnose</span>(TokStart, diag::lex_unterminated_string);</td></tr><tr><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1151</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"> <span style="color:rgb(167,29,93)">return</span> <span style="color:rgb(0,134,179)">formToken</span>(tok::unknown, TokStart);</td></tr><tr><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1152</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"> }</td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td rowspan="2" style="padding:8px 10px;width:350px;min-width:350px;max-width:350px;vertical-align:top"><a href="https://github.com/apple/swift/commit/2f44c0038c5a53e6ee4bb8f0a0fec4c3bd5d79a2" style="color:rgb(64,120,192);text-decoration:none;font-stretch:normal;font-size:11px;line-height:normal;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;float:right;background-color:transparent" target="_blank">2f44c00</a><img alt="@lattner" height="32" src="https://avatars0.githubusercontent.com/u/15152540?v=3&s=64" width="32" style="border:0px;display:inline-block;overflow:hidden;line-height:1;vertical-align:middle;border-radius:3px;float:left;margin-right:5px"><span style="max-width:230px;display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1;vertical-align:top;font-weight:bold"><a href="https://github.com/apple/swift/commit/2f44c0038c5a53e6ee4bb8f0a0fec4c3bd5d79a2" title="Initial stab at implementing string literal interpolation for simple expressions,
e.g. "foo is \(i+j)". This implements rdar://11223686
Doug implemented all the hard parts of this. I ripped out support for nested string
literals (i.e. string literals within an interpolated string), which simplified the
approach and defined away some problems with his patch in progress. I plan a few refinements
on top of this basic patch.
Swift SVN r1738" style="color:rgb(51,51,51);text-decoration:none;background-color:transparent" target="_blank">Initial stab at implementing string literal interpolation for simple …</a></span><div style="color:rgb(118,118,118);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.1"><a href="https://github.com/lattner" rel="contributor" style="color:rgb(118,118,118);text-decoration:none;background-color:transparent" target="_blank">lattner</a> authored on May 4, 2012</div></td></tr><tr style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(233,233,233)"><td style="padding:0px 1px;width:2px;background-color:rgb(121,55,56)"></td><td style="padding:0px 10px;width:50px;min-width:50px;white-space:nowrap;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18px;vertical-align:top;text-align:right;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px;background-color:rgb(253,253,253)">1153</td><td style="padding:0px 10px;vertical-align:top;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap;overflow:visible;word-wrap:normal"> </td></tr></tbody></table></div><div class="gmail_extra"><br><div class="gmail_quote"><br></div><div class="gmail_quote">On Sat, Dec 12, 2015 at 2:02 AM, Alex Gordon <span dir="ltr"><<a href="mailto:alextgordon@gmail.com" target="_blank">alextgordon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>What is the reason that normal strings "..." don't support newlines? It's not traditionally seen in C-inspired languages, but it's hardly unusual outside that sphere[*]. Ruby and HTML are probably the most common examples, but apparently OCaml and Lisps also allow it?</div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>Among other reasons, Swift’s current behavior makes it straight-forward for the compiler to recover and handle the common error when you’ve forgotten to close a “. If \n’s were allowed in simple string literals, then everything to the end of the file is included in the string, and the only mistake is the missing “. This may seem like a minor thing, but matters a lot in an IDE context where you may have typed</div><div><br></div><div> let x = “foo</div><div><br></div><div>and just haven’t finished typing, and the entire buffer changes color or something.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Chris</div><div><br></div></font></span></div></div></blockquote></div><br></div>