{"id":47141,"date":"2025-03-19T15:18:22","date_gmt":"2025-03-19T19:18:22","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=47141"},"modified":"2025-03-19T20:05:34","modified_gmt":"2025-03-20T00:05:34","slug":"lifetime-dependencies-in-swift-6-2-and-beyond","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/03\/19\/lifetime-dependencies-in-swift-6-2-and-beyond\/","title":{"rendered":"Lifetime Dependencies in Swift 6.2 and Beyond"},"content":{"rendered":"<p><a href=\"https:\/\/forums.swift.org\/t\/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond\/78638\">John McCall<\/a>:<\/p>\n<blockquote cite=\"https:\/\/forums.swift.org\/t\/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond\/78638\"><p><a href=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0446-non-escapable.md\">SE-0446<\/a> 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 <a href=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0446-non-escapable.md#initializers-and-lifetime-dependencies\">lifetime dependencies<\/a>. The design and implementation of that proposal is still in progress. In the meantime, <a href=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0456-stdlib-span-properties.md\">SE-0456<\/a> added multiple properties to the standard library which return <code>Span<\/code>, a non-escapable type. These properties have been defined using a feature, <code>@lifetime<\/code>, that is not yet officially in the language.<\/p><p>[&#8230;]<\/p><p>However, we&rsquo;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 <code>Span<\/code> in their own code and APIs in the meantime.<\/p><p>[&#8230;]<\/p><p>The Language Steering Group is therefore considering introducing <code>@lifetime<\/code> as a <em>supported experimental feature<\/em> in Swift 6.2.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2023\/03\/22\/swift-proposal-noncopyable-structs-and-enums\/\">Swift Proposal: Noncopyable Structs and Enums<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/11\/29\/introduction-to-move-only-types-in-swift\/\">Introduction to Move-Only Types in Swift<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/07\/26\/swift-proposal-move-function\/\">Swift Proposal: Move Function<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/12\/23\/roadmap-for-improving-swift-performance-predictability\/\">Roadmap for Improving Swift Performance Predictability<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>John McCall: 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-03-19T19:18:24Z","apple_news_api_id":"7c7310c2-1ed1-4a9a-853d-beba5c432756","apple_news_api_modified_at":"2025-03-19T19:19:11Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AfHMQwh7RSpqFPb66XEMnVg","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[46,571,71,901],"class_list":["post-47141","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-memory-management","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=47141"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47141\/revisions"}],"predecessor-version":[{"id":47143,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47141\/revisions\/47143"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=47141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=47141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=47141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}