-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Non-Escapable Types #2304
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
Merged
Merged
Non-Escapable Types #2304
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
PsychoH13
reviewed
Feb 6, 2024
xwu
reviewed
Jun 18, 2024
xwu
reviewed
Jun 18, 2024
lorentey
reviewed
Aug 6, 2024
- I may be wrong on some of these, but this needs to be consistent with Swift documentation.
Editing suggestions for non-escapable
Co-authored-by: Karoy Lorentey <[email protected]>
Clearly tie initialization of nonescapable values to the experimental lifetime dependencies feature.
Update Future direction: Initializers and Lifetime Dependencies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.