You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/NNNN-lifetime-dependency.md
+4-32Lines changed: 4 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -761,43 +761,15 @@ This was changed after we realized that there was in practice almost always a si
761
761
762
762
## Future Directions
763
763
764
-
#### Lifetime Dependencies for Computed Properties
765
-
766
-
It would be useful to allow lifetime dependencies between `self` and the value returned by a computed property.
767
-
There is some ambiguity here, since resilience hides the distinction between a computed and stored property.
768
-
In particular, the resilience concern might prevent us from inferring lifetime dependencies for properties across module boundaries.
769
-
The notation for an explicit lifetime dependency on a property might look like the following:
770
-
771
-
```swift
772
-
structContainer {
773
-
var view: dependsOn(self) ReturnType { get }
774
-
}
775
-
776
-
structType1: ~Escapable {
777
-
var childView: dependsOn(self) Type1 { get }
778
-
}
779
-
```
780
-
781
-
We expect that the lifetime notation would be mandatory for any property that provided a `~Escapable` value.
782
-
783
-
#### Lifetime Dependencies for Escapable Types
764
+
### Lifetime Dependencies for Escapable Types
784
765
785
766
This proposal has deliberately limited the application of lifetime dependencies to return types that are nonescapable.
786
767
This simplifies the model by identifying nonescapable types as exactly those types that can carry such dependencies.
787
768
It also helps simplify the enforcement of lifetime constraints by guaranteeing that constrained values cannot escape before being returned.
788
769
Most importantly, this restriction helps ensure that the new semantics (especially lifetime dependency inference) cannot accidentally break existing code.
789
770
We expect that in the future, additional investigation can reveal a way to relax this restriction.
790
771
791
-
#### Lifetime Dependencies between arguments
792
-
793
-
A caller may need assurance that a callee will honor a lifetime dependency between two arguments.
794
-
For example, if a function is going to destroy a container and a reference to that container in the process of computing some result,
795
-
it needs to guarantee that the reference is destroyed before the container:
0 commit comments