On Sat, Apr 22, 2017 at 3:21 AM, Thorsten Seitz <[email protected]> wrote:
> > Am 21.04.2017 um 20:48 schrieb Xiaodi Wu via swift-evolution < > [email protected]>: > > On Fri, Apr 21, 2017 at 1:45 PM, Erica Sadun <[email protected]> wrote: > >> >> On Apr 21, 2017, at 12:40 PM, Xiaodi Wu via swift-evolution < >> [email protected]> wrote: >> >> On Fri, Apr 21, 2017 at 8:48 AM, Robert Bennett via swift-evolution < >> [email protected]> 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? > > > I think „single-line“ and „multiline“ should foremost apply to the code > representation of a string and not its result. > Otherwise "foo\nbar“ would be a multiline string with your reasoning, > wouldn’t you agree? > I think Robert Bennett has summarized the differences between his view and my view of literals very well. Keep in mind we're talking about _string literals_, not strings. To me, a literal is something that represents its data as literally as possible. Therefore, what makes something a _multiline_ string literal is simple: it permits literal newlines. > Therefore a multiline string is one which is written over several lines of > *code* to make maintenance easier. > From that follows naturally that as soon as line breaks are introduced for > hard wrapping we are talking about multiline strings. > > In addition as soon as line breaks are introduced in the code the question > of indentation arises which is solved neatly with the multiline string > proposal by the position of the ending delimiter which is not possible with > single-line strings. > > -Thorsten > >
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
