Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-Escapable Types #2304

Merged
merged 26 commits into from
Sep 17, 2024
Merged

Non-Escapable Types #2304

merged 26 commits into from
Sep 17, 2024

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Feb 2, 2024

This is the first of two proposals covering this new feature:

It propose an Escapable type marker to indicate that a value of this type can escape the local scope -- by being stored in a global or returned, for example.
This new marker would be implicitly satisfied by all current Swift types to avoid breaking existing code and to reflect the expectation that most types can in fact be freely copied and assigned without limit.
We then add a new ~Escapable type requirement that can be used to selectively remove this capability.
We explain the motivation for such types and the basic capabilities and restrictions on their use.

The companion proposal "Lifetime Dependency Constraints for ~Escapable Values" proposes a set of annotations that selectively modify the constraints of ~Escapable types so they can be used to provide accurate compile-time tracking of values that are inherently subsidiary to some other value (for example, iterators over collections or slices that must not outlive the container to which they refer).

These are part of the BufferView roadmap and are prerequisites for that type.

Briefly, non-escapable types are types that cannot "escape" the local
execution context.  These types can also participate in extended
lifetime dependency constraints.  This enables compile-time lifetime
enforcement for values that contain pointers into other values.  This
makes it possible to implement containers that require no runtime
lifetime management of their iterators or slice objects.

In particular, this is a foundational technology for BufferView.
@rjmccall rjmccall added LSG Contains topics under the domain of the Language Steering Group workgroup: blocked This proposal is blocked on some other consideration and removed workgroup: blocked This proposal is blocked on some other consideration labels Apr 1, 2024
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
proposals/NNNN-non-escapable.md Outdated Show resolved Hide resolved
@tbkka
Copy link
Contributor Author

tbkka commented Aug 23, 2024

I've incorporated a number of suggested edits from @glessard , @lorentey , and @atrick . Please let me know if you find any other issues.

tbkka and others added 5 commits August 23, 2024 16:31
Clearly tie initialization of nonescapable values to the experimental lifetime
dependencies feature.
Update Future direction: Initializers and Lifetime Dependencies
@jckarter jckarter merged commit de4e2e8 into swiftlang:main Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LSG Contains topics under the domain of the Language Steering Group
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants