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
Lifetime Dependency Annotations for Non-escapable Types #2305
base: main
Are you sure you want to change the base?
Conversation
Overhauled to reflect a fundamentally different syntax. We now have a single |
… pitch Pitch - apple/swift-evolution#2305 Changes highlights: @dependsOn(paramName) and @dependsOn(scoped argName) syntax @dependsOn(paramName) -> copy lifetime dependence for all parameters/self except when we have Escapable parameters/self, we assign scope lifetime dependence. Allow lifetime dependence on parameters without ownership modifier. Always infer copy lifetime dependence except when we have Escapable parameters/self, we infer scope lifetime dependence. Allow lifetime dependence inference on parameters without ownership modifier.
… pitch Pitch - apple/swift-evolution#2305 Changes highlights: @dependsOn(paramName) and @dependsOn(scoped argName) syntax @dependsOn(paramName) -> copy lifetime dependence for all parameters/self except when we have Escapable parameters/self, we assign scope lifetime dependence. Allow lifetime dependence on parameters without ownership modifier. Always infer copy lifetime dependence except when we have Escapable parameters/self, we infer scope lifetime dependence. Allow lifetime dependence inference on parameters without ownership modifier.
We need to separate description of the dependency itself -- which places a bound on when particular objects can be destroyed -- from the syntax. In particular, the syntax specifies a relationship between two objects, but that relationship is not always a lifetime dependency itself (because of "copied" dependencies).
… pitch Pitch - apple/swift-evolution#2305 Changes highlights: dependsOn(paramName) and dependsOn(scoped argName) syntax dependsOn(paramName) -> copy lifetime dependence for all parameters/self except when we have Escapable parameters/self, we assign scope lifetime dependence. Allow lifetime dependence on parameters without ownership modifier. Always infer copy lifetime dependence except when we have Escapable parameters/self, we infer scope lifetime dependence. Allow lifetime dependence inference on parameters without ownership modifier.
Also, fix the proposed syntax for properties
These would also be useable with methods that wish to declare a dependency on `self`. | ||
To reduce the burden of manually adding such annotations, we also propose inferring lifetime dependencies in certain common cases without requiring any additional annotations. | ||
|
||
This is a key requirement for the `StorageView` type (previously called `BufferView`) being discussed elsewhere, and is closely related to the proposal for `~Escapable` types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have named this construct Span
. Please let's avoid mentioning its deadnames; proposals are forever, and we really need to avoid indefinitely propagating these obsolete names.
This is a key requirement for the `StorageView` type (previously called `BufferView`) being discussed elsewhere, and is closely related to the proposal for `~Escapable` types. | |
This is a key requirement for the `Span` type that is being discussed elsewhere, and is closely related to the proposal for `~Escapable` types. |
…bling proposal.
Changed `StorageView` and `BufferReference` to `Span` to match the si…
This is a companion proposal to "Non-Escapable Types".
It proposes a set of annotations that can be used to relate the lifetimes of two objects. For example, this can be used to ensure that a "slice" or "iterator" object that holds a pointer into some container does not outlive the container.