Skip to content

Commit d414e84

Browse files
committed
Remove the "Further discussions" section because this needs to be a small scope review
and those suggestions changes aren't possible to change at this point. Include a few editorial changes and kick off review.
1 parent b7641b0 commit d414e84

File tree

1 file changed

+13
-44
lines changed

1 file changed

+13
-44
lines changed

proposals/XXXX-newline-escape-in-strings.md renamed to proposals/0182-newline-escape-in-strings.md

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# String Newline Escaping
22

3-
* Proposal: [SE-XXXX](XXXX-newline-escape-in-strings.md)
3+
* Proposal: [SE-0182](0182-newline-escape-in-strings.md)
44
* Authors: [John Holdsworth](https://github.com/johnno1962), [David Hart](https://github.com/hartbit), [Adrian Zubarev](https://github.com/DevAndArtist)
5-
* Review Manager: TBD
6-
* Status: **Awaiting review**
5+
* Review Manager: [Chris Lattner](https://github.com/lattner)
6+
* Status: **Active review (July 12...17)**
77

88
* Previous Proposal: [SE-0168](0168-multi-line-string-literals.md)
99

1010
## Introduction
1111

12-
This proposal introduces the ability to escape newlines in single and multi-line strings to improve readability and maintenance of source material containing excessively long lines.
13-
14-
This proposal adds onto [SE-0168](0168-multi-line-string-literals.md).
12+
This proposal is a refinement of [SE-0168](0168-multi-line-string-literals.md) which introduces the ability to escape newlines in single and multi-line strings to improve readability and maintenance of source material containing excessively long lines.
1513

1614
Swift-evolution thread: [Discussion thread](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170417/035923.html)
1715

@@ -41,7 +39,7 @@ Incorporating a string continuation character is well founded, used in other dev
4139

4240
## Detailed design
4341

44-
This proposal introduces `\` as a line continuation character which escapes newlines matching the following regular-expression: `/\\[ \t]*\n/`. In other terms, line continuation requires a `\` character, followed by zero or more whitespace characters, followed by a newline character. All those characters are omitted from the resulting string.
42+
This proposal introduces `\` as a line continuation character which escapes newlines matching the following regular-expression: `/\\[ \t]*\n/`. In other terms, line continuation requires a `\` character, followed by zero or more horizontal whitespace characters, followed by a newline character. All those characters are omitted from the resulting string.
4543

4644
As a consequence, these rules follow:
4745

@@ -69,43 +67,9 @@ assert(str1 == str2)
6967

7068
This does not affect the indentation removal feature of multiline strings and does not suggest that indentation removal should be added to conventional strings but it does give them consistent treatment.
7169

72-
## Further discussions
73-
74-
The following topics are related to escaping newlines. If newline-escaping where accepted it may be appropriate to revisit these decisions when considering this proposal though that shouldn't be the focus of the discussion.
75-
76-
### Reconsidering stripping the last newline in multi-line strings
77-
78-
When SE-0168 was reviewed, it was decided to strip the last newline in multi-line strings. Doing the opposite would have been ill-advised without a line continuation character to escape it when necessary. If this proposal is accepted, it might be worth reconsidering this decision and include the final newline in the literal. For example, it would allow easier concatenation of multi-line strings:
79-
80-
```swift
81-
var xml = """
82-
<?xml version="1.0"?>
83-
<catalog>
84-
"""
85-
86-
for (id, author, title, genre, price) in bookTuples {
87-
xml += """
88-
<book id="bk\(id)">
89-
<author>\(author)</author>
90-
<title>\(title)</title>
91-
<genre>\(genre)</genre>
92-
<price>\(price)</price>
93-
</book>
94-
"""
95-
}
96-
97-
xml += """
98-
</catalog>
99-
"""
100-
```
101-
102-
### Warning about trailing whitespace in multi-line strings
103-
104-
During the implementation of SE-0168, it was decided not to warn about trailing whitespace in multi-line strings. One of the reasons brought up was that the only way to silence the warning was with a no-op character sequence at the end of the line; the only option back then was `\("")`, which is less than ideal. With this proposal, a slightly more elegant solution is now available: `\n\`.
105-
10670
## Source compatibility
10771

108-
As this proposal is additive proposing a syntax that is not currently allowed in Swift this does not affect existing source.
72+
This proposal does not affect existing source, because it is purely additive - enabling syntax that is not currently allowed in Swift.
10973

11074
## Effect on ABI stability
11175

@@ -117,7 +81,7 @@ This proposal does not affect ABI resilience.
11781

11882
## Alternatives considered
11983

120-
It has been heavily debated between the authors of the proposals wether newline escaping should be supported in single-line strings. One argument against it is that the lack of indentation stripping in single-line strings forces strings to include no indentation, hindering the readability of code by visually breaking scopes when returning the column 1:
84+
It has been heavily debated between the authors of the proposals whether newline escaping should be supported in single-line strings. One argument against it is that the lack of indentation stripping in single-line strings forces strings to include no indentation, hindering the readability of code by visually breaking scopes when returning the column 1:
12185

12286
```swift
12387
class Messager {
@@ -133,4 +97,9 @@ empty message, it has no meaning.")
13397
}
13498
```
13599

136-
Another counter-argument is that further proposals might come up to fix this problem by introducing indentation stripping to single-line strings, muddying the distinction between single and multi-line strings.
100+
Another argument against it is that lines that are sufficiently long and/or complex could use
101+
multi-line string literals with newline escaping, so there is no need to include them in single
102+
quoted strings.
103+
104+
A counter-argument is that it is important to keep single and triple quoted strings consistent
105+
with each other.

0 commit comments

Comments
 (0)