[swift-evolution] [Accepted] SE-0168: Multi-Line String Literals
xiaodi.wu at gmail.com
Wed Apr 19 17:04:37 CDT 2017
Not dealing with trailing whitespaces is indeed the right decision, I
think. The idea has always been that one key advantage for this syntax is
that one can copy and paste the greatest possible amount of multi-line text
without having to edit each line.
Many source documents can have such trailing spaces at the end of lines.
For example, I'm sure that some of the HTML documents I've written, unless
linted, have such spaces. They are both invisible and harmless in the
original source document.
They would also do no harm in a multi-line literal. There is no need to
warn or error in that scenario, and the proposed workaround requires a
rather ugly escape pattern to cure this non-harm.
On Wed, Apr 19, 2017 at 16:43 Adrian Zubarev via swift-evolution <
swift-evolution at swift.org> wrote:
> First of all, thank you for accepting the proposal. However I still have
> one single concern left about the trailing whitespaces. Will the final
> implemented version raise a warning or produce an error when there are
> trailing whitespaces?
> The whole idea of a trailing \ was in first place to prevent new line
> injection but also for trailing whitespace character precision.
> The following example could have 1000 characters, but a different
> developer who reads the code wouldn’t even notice.
> That’s what the trailing backslash was meant for. To prevent unwanted
> whitespaces, or if you really need them, to force you to be precise about
> Adrian Zubarev
> Sent with Airmail
> Am 19. April 2017 um 22:03:31, Joe Groff via swift-evolution (
> swift-evolution at swift.org) schrieb:
> - It should be clarified that *multiline strings support the same escapes
> and interpolations* as single-line strings. This allows a literal """ to
> be written \""". Discussion on the list raised the idea of allowing a line
> to end with \ to "escape" the newline and elide it from the value of the
> literal; the core team had concerns about only allowing that inside
> multi-line literals and felt that that could also be considered later as an
> additive feature.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution