[swift-evolution] multi-line string literals

Kametrixom Tikara kametrixom at icloud.com
Fri Dec 11 17:48:39 CST 2015


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 <mailto: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/20151212/7b3e6ed2/attachment.html>


More information about the swift-evolution mailing list