[swift-evolution] multi-line string literals

Jordan Rose jordan_rose at apple.com
Wed Dec 16 12:34:22 CST 2015

> On Dec 16, 2015, at 5:24 , Rainer Brockerhoff via swift-evolution <swift-evolution at swift.org> wrote:
> On 12/14/15 20:40, swift-evolution-request at swift.org wrote:
>> Date: Mon, 14 Dec 2015 12:38:14 -0800
>> From: Chris Lattner <clattner at apple.com>
>> Subject: Re: [swift-evolution] multi-line string literals
>> Message-ID: <509AEA5D-81C8-48A5-B676-B059624ED4E3 at apple.com>
>>>> On Dec 11, 2015, at 4:03 PM, Travis Tilley <ttilley at gmail.com> wrote:
>>>> Fair enough. Plus if Chris Lattner has any strong opinions about the behavior of single quotes, which might be the case given the existing code for handling them in Lexer.cpp, backticks are a damn good alternative. I'd still like to wait to hear back from him or someone else on the core team about that one.
>> Support for single quoted literals like 'x' was a legacy feature for C-like character literals that we explored before the design of Character went to where it is now.  I’d be fine ripping it out and repurposing it.
> IIRC the problems with C character literals began when they began to
> generalize the original concept of representing a single ASCII character.
> Repurposing 'x' to something like multiline strings might be confusing
> to people migrating from other languages, but perhaps refocusing on the
> original usage would not be?
> IOW, 'x' where x must be a Character, that is, an extended Unicode
> grapheme cluster — represented in the source code as UTF8 or with the \u
> notation. A shortcut for typing Character("x").

We actually had this at one point, but it turned out that sometimes you wanted a Character and sometimes a UnicodeScalar, and in both cases your algorithm was probably wrong (cf. String is no longer a CollectionType). At that point it didn't offer any benefits over just regular string syntax, and it freed up the syntax for something else.

There's a fair amount of precedent for single-quoted strings being:
- single characters (C, Java, C#)
- unprocessed strings (shell scripts, Ruby)
- exactly the same as double-quoted strings (Python)

I (personally) wouldn't want them for multi-line literals, though.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/79d830c5/attachment.html>

More information about the swift-evolution mailing list