Skip to content

Commit aed8750

Browse files
committed
Syntax update: dependsOn(self).
1 parent 992b2fe commit aed8750

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

proposals/NNNN-lifetime-dependency.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ func mayReassign(span: dependsOn(a) inout [Int], to a: [Int]) {
302302
}
303303
```
304304

305-
A `selfDependsOn` keyword is required to indicate that a method's implicit `self` depends on another parameter.
305+
The `dependsOn(self:)` keyword is required to indicate that a method's implicit `self` depends on another parameter.
306306

307307
```swift
308308
extension Span {
309-
mutating selfDependsOn(other) func reassign(other: Span<T>) {
309+
mutating dependsOn(self: other) func reassign(other: Span<T>) {
310310
self = other // ✅ OK: 'self' depends on 'other'
311311
}
312312
}
@@ -329,8 +329,8 @@ Structural composition is an important use case for nonescapable types. Getting
329329
```swift
330330
struct Container<Element>: ~Escapable {
331331
var element: Element {
332-
/* dependsOn(self) */ get { ... }
333-
/* selfDependsOn(newValue) */ set { ... }
332+
get /* dependsOn(self) */ { ... }
333+
/* dependsOn(self: newValue) */ set { ... }
334334
}
335335

336336
init(element: Element) /* -> dependsOn(element) Self */ {...}
@@ -534,11 +534,10 @@ This new syntax adds an optional `dependsOn(...)` lifetime modifier just before
534534
> *parameter-type-annotation* → : *attributes?* *lifetime-modifiers?* *parameter-modifier*? *type*
535535
>
536536
537-
The new syntax also adds an optional `selfDependsOn(...)` lifetime modifier before function declarations. This extends *declaration-modifier* as follows:
537+
The new syntax also adds an optional `dependsOn(self:...)` lifetime modifier before function declarations. This extends *declaration-modifier* as follows:
538538

539539
>
540-
> *declaration-modifier**self-lifetime-modifier* \
541-
> *self-lifetime-modifier***`selfDependsOn`** **`(`** *lifetime-dependent-list* **`)`**
540+
> *declaration-modifier***`dependsOn`** **`(`** **`self`** **`:`** *lifetime-dependent-list* **`)`**
542541
>
543542
544543
The *lifetime-dependent* argument to the lifetime modifier is one of the following:

0 commit comments

Comments
 (0)