[swift-evolution] multi-line string literals

Travis Tilley ttilley at gmail.com
Fri Dec 11 18:03:49 CST 2015


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.


-Travis Tilley


On Fri, Dec 11, 2015 at 6:48 PM, Kametrixom Tikara <kametrixom at icloud.com>
wrote:

> I think it can just work like this:
>
> struct Test {
>     func hi() {
>         let json =
>         ```             // Indentation to the left of the back ticks gets
> erased and nothing more
>         {
>             "Hello": 3
>         }
>         ```
>
>
>         let str =
>         ```
>         "This is a string"
>     ```     // Compiler error: Back ticks not aligned
>
>
>         let hs =
>         ```
>     main = interact id      // Compiler error: too little indentation
>         ```
>     }
> }
>
> By just not supporting more complex indentation erasure, we can avoid
> potential confusion.
>
> On 12 Dec 2015, at 00:35, Travis Tilley <ttilley at gmail.com> wrote:
>
> Fair enough point. But wouldn't we still want indentation erasure which
> would be counter-intuitive for what we expect from triple backticks?
> like... a block of json defined in the middle of a function, this having
> maybe two levels of indentation to be erased.
>
>
> On Fri, Dec 11, 2015 at 6:26 PM, Drew Crawford <drew at sealedabstract.com>
> wrote:
>
>> That's an interesting idea!  What about """ for escaped strings and ```
>> for unescaped literal strings?
>>
>> 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.
>>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151211/f36c746a/attachment.html>


More information about the swift-evolution mailing list