Lifetime Dependencies in Swift 6.2 and Beyond
SE-0446 added basic language support in Swift for non-escapable types, whose values are restricted in scope. However, it intentionally left out the ability for functions and properties to return values of these types, pending a future proposal to add lifetime dependencies. The design and implementation of that proposal is still in progress. In the meantime, SE-0456 added multiple properties to the standard library which return
Span
, a non-escapable type. These properties have been defined using a feature,@lifetime
, that is not yet officially in the language.[…]
However, we’re conscious that the development of that feature may take a few releases, and we want developers to be able to take advantage of non-escapable types like
Span
in their own code and APIs in the meantime.[…]
The Language Steering Group is therefore considering introducing
@lifetime
as a supported experimental feature in Swift 6.2.
Previously:
- Swift Proposal: Noncopyable Structs and Enums
- Introduction to Move-Only Types in Swift
- Swift Proposal: Move Function
- Roadmap for Improving Swift Performance Predictability