[swift-evolution] multi-line string literals.

Brent Royal-Gordon brent at architechies.com
Thu Apr 28 00:26:49 CDT 2016


> White space seems “implementable”, but I’m not sure that it is good.  Visually, it would break up the string literal and make it less obviously a unit.
> 
> Comments on the same line as a string chunk should *not* be split out IMO, in:
> 
>    let s = “fooo  // hello world
>               “ nice to know you”
> 
> the “hello world” text should be included in the literal.  I suppose it would be possible to allow comments on whitespace lines, but I don’t see a reason to do that.  I’d suggest starting simple, since that could always be added down the road if there was great demand.

What I'm actually suggesting is that comments *before* the continuing quote would be honored without terminating the literal:

let xml = "<?xml version=\"1.0\"?>
          "<catalog>
          "	<book id=\"bk101\" empty=\"\">
//          "		<author>\(author)</author>
          "	</book>
          "</catalog>"

A // or /* after the continuing quote would still be part of the literal.

I'm preparing a second draft without that feature, though, so if you still think it's a bad idea, I'll drop it.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list