[swift-evolution] multi-line string literals.

Ricardo Parada rparada at mac.com
Mon Apr 3 10:09:06 CDT 2017


Hi Adrian,

I'm not sure if I am understanding what you are saying.

To me a multi-line string literal is not about continuing a "very long string" into the next line.  

To me a multi-line string literal is about having a string literal that represents multiple lines of text, where each line is separated by a new line character.  It's just like when you look at a text file in the editor and you don't see the \n at the end of each line.  You just see multiple lines of text.  Same philosophy applies here, but with some useful features such as being able to use escape \, interpolation and quotes mainly.

The continuation character serves as a visual guide of the beginning of each line and to help you align/indent the multiple lines of text.

I was proposing that the multi-line string literal automatically ends when there is no continuation character on the next line.  But it could also use the same one that was used to start it, either """ or "M.

I am sure we'll find a hole in every proposed solution, but I think the one that takes care of 99% of the cases should be the one.

Regards


> On Apr 3, 2017, at 10:44 AM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:
> 
> IMHO this is what multi-lined strings are meant for in first place, for better code readability without precision tradeoffs. You’re not expecting multi-lined chained methods to do something else as they’re meant for. We’re allowing multi lines there for readability not for more functionality.
> 
> That’s why I disagree that multi-line strings should add new lines automatically to the string.
> 
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> Am 3. April 2017 um 16:33:05, Ricardo Parada (rparada at mac.com <mailto:rparada at mac.com>) schrieb:
> 
>> let veryLongString2 = "word word word" +
>> "word word word" +
>>   "word word word"
>> 
> 
> 

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


More information about the swift-evolution mailing list