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.
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
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution