[swift-evolution] Long, multiline strings

Chris Lattner clattner at apple.com
Mon Dec 21 12:59:08 CST 2015


> On Dec 21, 2015, at 10:02 AM, Carlos Rodríguez Domínguez via swift-evolution <swift-evolution at swift.org> wrote:
> 
> In many cases, it is necessary to include in the code very long strings, spanning multiple lines. An example could be to include a piece of JavaScript code, XML, HTML, JSON, etc. Currently, we include those strings between ““, which makes it impossible for the IDE to understand that we are “including” external code, potentially providing syntax highlighting, autocompletion, etc. Moreover, at the end of each line it is necessary to include a “\n” character and each “ character needs to be escaped.

Hi Carlos,

Please catch up on the "multi-line string literals” thread, which discusses this exact topic.

-Chris

> 
> My idea is to include a new operator to generate multiline strings, similar to PHP, in which you can write something like this:
> 
> $text = <<<EOT 
>   Place your text between the EOT. It's
>   the delimiter that ends the text
>   of your multiline string.
>   $var
> EOT;
> This new feature could be highly beneficial, since it is increasingly common to mix multiple codes inside our own code. Furthermore, it could open the possibility to use Swift in Web environments in a friendlier manner (e.g. to generate HTML code faster, with syntax coloring, etc.). 
> 
> - Carlos
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151221/7a0fdc23/attachment.html>


More information about the swift-evolution mailing list