[swift-evolution] multi-line string literals
Alex Gordon
alextgordon at gmail.com
Mon Dec 14 17:26:19 CST 2015
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.
This is why text editors have autopair.
- Alex
On Mon, Dec 14, 2015 at 8:40 PM, Chris Lattner <clattner at apple.com> wrote:
>
> On Dec 11, 2015, at 11:25 PM, Travis Tilley via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> You'd have to ask Chris Latter and Dmitri Gribenko, who are responsible
> for the lines in Lexer.cpp that prevent it:
>
>
> 22610d5
> <https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf>[image:
> @lattner]substantially improve error recovery for erroneous character and
> stri…
> <https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf>
> lattner <https://github.com/lattner> authored on May 20, 2013
> 11471148 // String literals cannot have \n or \r in them.3bee330
> <https://github.com/apple/swift/commit/3bee330e5068eb6ed4e825ff77b9e7615758eb47>[image:
> @gribozavr]Lexer: don't inf loop on an unterminated string literal near
> EOF
> <https://github.com/apple/swift/commit/3bee330e5068eb6ed4e825ff77b9e7615758eb47>
> gribozavr <https://github.com/gribozavr> authored on Aug 22, 2013
> 1149 if (*CurPtr == '\r' || *CurPtr == '\n' || CurPtr == BufferEnd) {
> 22610d5
> <https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf>[image:
> @lattner]substantially improve error recovery for erroneous character and
> stri…
> <https://github.com/apple/swift/commit/22610d5db8faa75354c42066fc586aa996a96ebf>
> lattner <https://github.com/lattner> authored on May 20, 2013
> 1150 diagnose(TokStart, diag::lex_unterminated_string);1151 return
> formToken(tok::unknown, TokStart);1152 }2f44c00
> <https://github.com/apple/swift/commit/2f44c0038c5a53e6ee4bb8f0a0fec4c3bd5d79a2>[image:
> @lattner]Initial stab at implementing string literal interpolation for
> simple …
> <https://github.com/apple/swift/commit/2f44c0038c5a53e6ee4bb8f0a0fec4c3bd5d79a2>
> lattner <https://github.com/lattner> authored on May 4, 2012
> 1153
>
>
> On Sat, Dec 12, 2015 at 2:02 AM, Alex Gordon <alextgordon at gmail.com>
> wrote:
>
>> 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?
>>
>
> 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
>
> let x = “foo
>
> and just haven’t finished typing, and the entire buffer changes color or
> something.
>
> -Chris
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/18d8e192/attachment.html>
More information about the swift-evolution
mailing list