Skip to content

Commit 174b0f0

Browse files
authored
SE-0439: Indent code blocks under bullet points (#2574)
1 parent 554069f commit 174b0f0

File tree

1 file changed

+128
-131
lines changed

1 file changed

+128
-131
lines changed

proposals/0439-trailing-comma-lists.md

Lines changed: 128 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Other comma-separated lists in the language could also benefit from the flexibil
3232

3333
```swift
3434
let numbers = [1, 2, 0, 3, 4, 0, 0, 5]
35-
35+
3636
let subsequences = numbers.split(
3737
separator: 0,
3838
// maxSplits: 1
@@ -51,177 +51,174 @@ This proposal adds support for trailing commas in comma-separated lists when the
5151

5252
- Tuples and tuple patterns.
5353

54-
```swift
55-
56-
let velocity = (
57-
1.66007664274403694e-03,
58-
7.69901118419740425e-03,
59-
6.90460016972063023e-05,
60-
)
61-
62-
let (
63-
velocityX,
64-
velocityY,
65-
velocityZ,
66-
) = velocity
54+
```swift
55+
let velocity = (
56+
1.66007664274403694e-03,
57+
7.69901118419740425e-03,
58+
6.90460016972063023e-05,
59+
)
6760

68-
```
61+
let (
62+
velocityX,
63+
velocityY,
64+
velocityZ,
65+
) = velocity
66+
```
6967

7068
- Parameter and argument lists of initializers, functions, enum associated values, expression macros, attributes, and availability specs.
7169

72-
```swift
73-
74-
func foo(
75-
input1: Int = 0,
76-
input2: Int = 0,
77-
) { }
78-
79-
foo(
80-
input1: 1,
81-
input2: 1,
82-
)
83-
84-
struct S {
85-
init(
70+
```swift
71+
func foo(
8672
input1: Int = 0,
8773
input2: Int = 0,
8874
) { }
89-
}
9075

91-
enum E {
92-
case foo(
93-
input1: Int = 0,
94-
input2: Int = 0,
76+
foo(
77+
input1: 1,
78+
input2: 1,
9579
)
96-
}
9780

98-
@Foo(
99-
"input 1",
100-
"input 2",
101-
"input 3",
102-
)
103-
struct S { }
104-
105-
#foo(
106-
"input 1",
107-
"input 2",
108-
"input 3",
109-
)
81+
struct S {
82+
init(
83+
input1: Int = 0,
84+
input2: Int = 0,
85+
) { }
86+
}
87+
88+
enum E {
89+
case foo(
90+
input1: Int = 0,
91+
input2: Int = 0,
92+
)
93+
}
94+
95+
@Foo(
96+
"input 1",
97+
"input 2",
98+
"input 3",
99+
)
100+
struct S { }
110101

111-
struct S {
112102
#foo(
113103
"input 1",
114104
"input 2",
115105
"input 3",
116106
)
117-
}
118107

119-
if #unavailable(
120-
iOS 15,
121-
watchOS 9,
122-
) { }
108+
struct S {
109+
#foo(
110+
"input 1",
111+
"input 2",
112+
"input 3",
113+
)
114+
}
115+
116+
if #unavailable(
117+
iOS 15,
118+
watchOS 9,
119+
) { }
120+
```
123121

124-
```
125122
- Subscripts, including key path subscripts.
126123

127-
```swift
128-
let value = m[
129-
x,
130-
y,
131-
]
124+
```swift
125+
let value = m[
126+
x,
127+
y,
128+
]
132129

133-
let keyPath = \Foo.bar[
134-
x,
135-
y,
136-
]
130+
let keyPath = \Foo.bar[
131+
x,
132+
y,
133+
]
137134

138-
f(\.[
139-
x,
140-
y,
141-
])
142-
```
135+
f(\.[
136+
x,
137+
y,
138+
])
139+
```
143140

144141
- `if`, `guard` and `while` condition lists.
145142

146-
```swift
147-
if
148-
condition1,
149-
condition2,
150-
{ }
151-
152-
while
153-
condition1,
154-
condition2,
155-
{ }
156-
157-
guard
158-
condition1,
159-
condition2,
160-
else { }
161-
```
143+
```swift
144+
if
145+
condition1,
146+
condition2,
147+
{ }
148+
149+
while
150+
condition1,
151+
condition2,
152+
{ }
153+
154+
guard
155+
condition1,
156+
condition2,
157+
else { }
158+
```
162159

163160
- `switch` case labels.
164161

165-
```swift
166-
switch number {
167-
case
168-
1,
169-
2,
170-
:
171-
...
172-
default:
173-
..
174-
}
175-
```
162+
```swift
163+
switch number {
164+
case
165+
1,
166+
2,
167+
:
168+
...
169+
default:
170+
..
171+
}
172+
```
176173

177174
- Closure capture lists.
178175

179-
```swift
180-
{ [
181-
capturedValue1,
182-
capturedValue2,
183-
] in
184-
}
185-
```
176+
```swift
177+
{ [
178+
capturedValue1,
179+
capturedValue2,
180+
] in
181+
}
182+
```
186183

187184
- Inheritance clauses.
188185

189-
```swift
190-
struct S:
191-
P1,
192-
P2,
193-
P3,
194-
{ }
195-
```
186+
```swift
187+
struct S:
188+
P1,
189+
P2,
190+
P3,
191+
{ }
192+
```
196193

197194
- Generic parameters.
198195

199-
```swift
200-
struct S<
201-
T1,
202-
T2,
203-
T3,
204-
> { }
205-
```
196+
```swift
197+
struct S<
198+
T1,
199+
T2,
200+
T3,
201+
> { }
202+
```
206203

207204
- Generic `where` clauses.
208205

209-
```swift
210-
struct S<
211-
T1,
212-
T2,
213-
T3
214-
> where
215-
T1: P1,
216-
T2: P2,
217-
{ }
218-
```
206+
```swift
207+
struct S<
208+
T1,
209+
T2,
210+
T3
211+
> where
212+
T1: P1,
213+
T2: P2,
214+
{ }
215+
```
219216

220217
- String interpolation
221218

222-
```swift
223-
let s = "\(1, 2,)"
224-
```
219+
```swift
220+
let s = "\(1, 2,)"
221+
```
225222

226223
## Detailed Design
227224

@@ -278,7 +275,7 @@ if
278275
condition2,
279276
{ // ❌ Function produces expected type 'Bool'; did you mean to call it with '()'?
280277
return true
281-
}
278+
}
282279

283280
{ print("something") }
284281
```
@@ -293,7 +290,7 @@ if
293290
condition2,
294291
{
295292
return true
296-
}
293+
}
297294

298295
{ print("something") } // ❌ Closure expression is unused
299296
```

0 commit comments

Comments
 (0)