[Accepted] SE-0168: Multi-Line String Literals


(Christopher Kornher) #1

Sorry, I don't follow. What's this about paragraphs?

This was a common example of the many types of textual input that would benefit from concatenation characters in multiline text. Using ‘\’ as a continuation/concatenation character has been in common use for decades. Refer to the usage section here: https://en.wikipedia.org/wiki/Backslash

I am sure that you can find many examples if you care to search for them.

···

On Apr 21, 2017, at 12:58 PM, Xiaodi Wu <xiaodi.wu@gmail.com <mailto:xiaodi.wu@gmail.com>> wrote:

On Fri, Apr 21, 2017 at 1:56 PM, Christopher Kornher <ckornher@me.com <mailto:ckornher@me.com>> wrote:

On Apr 21, 2017, at 12:48 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Fri, Apr 21, 2017 at 1:45 PM, Erica Sadun <erica@ericasadun.com <mailto:erica@ericasadun.com>> wrote:

On Apr 21, 2017, at 12:40 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Fri, Apr 21, 2017 at 8:48 AM, Robert Bennett via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Xiaodi, I think one thing you're neglecting is that users may never print out a multiline literal string at all. A string might never be printed or read by a human outside of the code it resides in. In this case it seems perfectly reasonable to ask that it be possible to format the string nicely in the code and disregard how it would actually be printed.

Can you give an example of such a use case, where a string is never seen by a human but one cannot insert literal newlines and would need elided ones instead?
The most common reason is that the code is maintained by a (non-human) developer, who wants to be able to see and update the code in a readable form, but that represents a single line that will automatically wrapped by, for example, a UITextView for (human) consumption.

A different scenario from what Robert's describing, but sure. This goes to my question to David Hart. Isn't this an argument for a feature to allow breaking a single-line string literal across multiple lines? What makes this a use case for some feature for _multiline_ string literals in particular?

paragraphs are denoted by `\n` in almost every rich text tool / library

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Begin forwarded message:

From: Christopher Kornher <ckornher@me.com>
Subject: Re: [swift-evolution] [Accepted] SE-0168: Multi-Line String Literals
Date: April 21, 2017 at 12:56:54 PM MDT
To: Xiaodi Wu <xiaodi.wu@gmail.com>

On Apr 21, 2017, at 12:48 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Fri, Apr 21, 2017 at 1:45 PM, Erica Sadun <erica@ericasadun.com <mailto:erica@ericasadun.com>> wrote:

On Apr 21, 2017, at 12:40 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Fri, Apr 21, 2017 at 8:48 AM, Robert Bennett via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Xiaodi, I think one thing you're neglecting is that users may never print out a multiline literal string at all. A string might never be printed or read by a human outside of the code it resides in. In this case it seems perfectly reasonable to ask that it be possible to format the string nicely in the code and disregard how it would actually be printed.

Can you give an example of such a use case, where a string is never seen by a human but one cannot insert literal newlines and would need elided ones instead?
The most common reason is that the code is maintained by a (non-human) developer, who wants to be able to see and update the code in a readable form, but that represents a single line that will automatically wrapped by, for example, a UITextView for (human) consumption.

A different scenario from what Robert's describing, but sure. This goes to my question to David Hart. Isn't this an argument for a feature to allow breaking a single-line string literal across multiple lines? What makes this a use case for some feature for _multiline_ string literals in particular?

paragraphs are denoted by `\n` in almost every rich text tool / library

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution