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

Xiaodi Wu xiaodi.wu at gmail.com
Sat Apr 22 11:02:57 CDT 2017


On Sat, Apr 22, 2017 at 10:42 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:

> On Sat, Apr 22, 2017 at 10:35 AM, Robert Bennett <rltbennett at icloud.com>
> wrote:
>
>> I'm not sure how we could implement breaking lines with \ for single line
>> strings. Either indentation has to be stripped from the broken line, or the
>> line must not be indented in which case nothing has been gained because
>> soft wrap would accomplish the same thing. (Is there an option I'm missing?)
>>
>
> Hence, perhaps, we could consider designs that involve breaking lines not
> a syntax other than `\`?
>

s/not/with/
(Hmm, I should really make sure my sentences are grammatical. Apologies.)

Now that we have """strings""", we could simply say: if you want to break a
>> string over multiple lines, use a """string""" as a "string" does not
>> permit this.
>>
>> On Apr 22, 2017, at 11:12 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>>
>> On Sat, Apr 22, 2017 at 3:38 AM, Brent Royal-Gordon <
>> brent at architechies.com> wrote:
>>
>>> On Apr 21, 2017, at 11:48 AM, Xiaodi Wu via swift-evolution <
>>> swift-evolution at swift.org> wrote:
>>>
>>> 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?
>>>
>>>
>>> Well, if you're breaking a string across several lines, you will want
>>> indentation stripping too. Are you suggesting we should also bring that
>>> feature to single-line string literals with escaped newlines?
>>>
>>
>> No, I am suggesting that whatever design is used for escaped newlines, if
>> at all possible it should be equally apt for "strings" and """strings"""
>> such that it will not require indentation stripping.
>>
>>
>>> --
>>> Brent Royal-Gordon
>>> Architechies
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170422/83dcf631/attachment.html>


More information about the swift-evolution mailing list