Skip to content

Commit f648b02

Browse files
committed
Use "copied lifetime dependency" more consistently
Also, fix the proposed syntax for properties
1 parent 2e82c6b commit f648b02

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

proposals/NNNN-lifetime-dependency.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct BufferReference<T>: ~Escapable {
8484
}
8585
```
8686

87-
Because this type is marked `~Escapable`, it cannot be returned from a function or even initialized without some way to relax the escapability restrictions.
87+
Because this type is marked as unconditionally `~Escapable`, it cannot be returned from a function or even initialized without some way to relax the escapability restrictions.
8888
This proposal provides a set of constraints that can tie the lifetime of a nonescapable value to the lifetime of some other value.
8989
In the most common cases, these constraints can be inferred automatically.
9090

@@ -136,7 +136,7 @@ In both this and the previous case, the lifetime of the return value is "scoped"
136136
Because lifetime dependencies can only be attached to nonescapable values, types that contain pointers will generally need to be nonescapable in order to provide safe semantics.
137137
As a result, **scoped lifetime dependencies** are the only possibility whenever an `Escapable` value (such as an Array or similar container) is providing a nonescapable value (such as the `BufferReference` or `MutatingBufferReference` in these examples).
138138

139-
#### Copy Lifetime Dependency
139+
#### Copied Lifetime Dependency
140140

141141
The case where a nonescapable value is used to produce another nonescapable value is somewhat different.
142142
Here's a typical example that constructs a new `BufferReference` from an existing one:
@@ -215,7 +215,7 @@ Given a method of this form:
215215
The behavior depends as above on the mutation-modifier and whether the defining type is escapable or nonescapable.
216216

217217
**Initializers:** An initializer can define lifetime dependencies on one or more arguments.
218-
In this case, we use the same rules same as for “Functions” above
218+
In this case, we use the same rules as for “Functions” above
219219
by using the convention that initializers can be viewed as functions that return `Self`:
220220

221221
```swift
@@ -248,7 +248,7 @@ struct NEStruct: ~Escapable {
248248
borrowing func f2(...) -> /* @dependsOn(self) */ NonescapableType
249249
mutating func f3(...) -> /* @dependsOn(self) */ NonescapableType
250250

251-
// Note: A copy lifetime dependency is legal here
251+
// Note: A copied lifetime dependency is legal here
252252
consuming func f4(...) -> /* @dependsOn(self) */ NonescapableType
253253
}
254254
```
@@ -440,15 +440,14 @@ The notation for an explicit lifetime dependency on a property might look like t
440440

441441
```swift
442442
struct Container {
443-
var view: ReturnType { borrowing get }
443+
var view: @dependsOn(self) ReturnType { get }
444444
}
445445

446-
extension Type1 {
447-
var transformedView: Type1 { consuming get }
446+
struct Type1: ~Escapable {
447+
var childView: @dependsOn(self) Type1 { get }
448448
}
449449
```
450450

451-
Where `borrowing` or `consuming` would indicate that the returned value has a lifetime dependency on `self`.
452451
We expect that the lifetime notation would be mandatory for any property that provided a `~Escapable` value.
453452

454453
#### Lifetime Dependencies for Escapable Types

0 commit comments

Comments
 (0)