@@ -293,9 +293,6 @@ Nonescapable function parameters may not outlive the function scope.
293
293
Consequently, nonescapable values can never be returned from a function.
294
294
Nonescapable values come into existence within the body of the initializer.
295
295
Naturally, the initializer must return its value, and this creates an exception to the rule.
296
- Without further language support, implementing a nonescapable initializer requires an unsafe construct.
297
- That unsafe handling is not covered by this proposal because we don't want to surface unnecessary unsafety in the language.
298
- Instead, a subsequent proposal will support safe initialization by allowing the initializer to specify lifetime dependencies on its parameters.
299
296
The parameters to the initializer typically indicate a lifetime that the nonescapable value cannot outlive.
300
297
An initializer may, for example, create a nonescapable value that depends on a container variable that is bound to an object with its own lifetime:
301
298
``` swift
@@ -309,9 +306,10 @@ consume container // `container` lifetime ends here
309
306
use (iterator) // 🛑 'iterator' outlives `container`
310
307
```
311
308
312
- Lifetime dependencies will make this and similar misuses into compile-time errors.
313
- This will allow developers to safely define and use values that contain pointers into
314
- other values, ensuring that the pointers never outlive the underlying storage.
309
+ Specifying a dependency from a function parameter to its nonescapable result currently requires an experimental lifetime dependency feature.
310
+ With lifetime dependencies, initialization of nonescapable types is safe: misuses similar to the one shown above are compile-time errors.
311
+ Adopting new syntax for lifetime dependencies merits a separate, focussed review.
312
+ Until then, initialization of nonescapable values remains experimental.
315
313
316
314
#### Expanding standard library types
317
315
0 commit comments