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

Safe Access to Contiguous Storage #2307

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Feb 6, 2024

This is a proposal for safe access to borrowed memory, formerly known as "BufferView".

This proposal is a companion to (and depends on) Non-Escapable Types and on Lifetime Dependency Annotations for Non-escapable Types.

@rjmccall rjmccall added workgroup: blocked This proposal is blocked on some other consideration LSG Contains topics under the domain of the Language Steering Group labels Apr 1, 2024
@atrick atrick self-requested a review April 26, 2024 04:28
proposals/nnnn-safe-shared-contiguous-storage.md Outdated Show resolved Hide resolved
proposals/nnnn-safe-shared-contiguous-storage.md Outdated Show resolved Hide resolved
proposals/nnnn-safe-shared-contiguous-storage.md Outdated Show resolved Hide resolved
proposals/nnnn-safe-shared-contiguous-storage.md Outdated Show resolved Hide resolved
proposals/nnnn-safe-shared-contiguous-storage.md Outdated Show resolved Hide resolved

## <a name="Indexing"></a>Appendix: Index and slicing design considerations

Early prototypes of this proposal defined an `Index` type, `Iterator` types, etc. We are proposing `Int`-based API and are deferring defining `Index` and `Iterator` until more of the non-escapable collection story is sorted out. The below is some of our research into different potential designs of an `Index` type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are okay with having an Index type on Span, and we must be proposing it above. (UnsafeBufferPointer has sunk the concrete concept of an Index down into the ownership model in SE-0437. Whatever shape we will propose for a collection-like container of noncopyable elements, it will include the idea of an escaping Index, with this exact name.)

(Iterator on the other hand is not the right name for a borrowing iterator type, as the classic Sequence protocol reserves this name for its unified borrowing+consuming iterator. That iterator shape does not translate to the ownership model. Sequence will be split into two+ variants, with each variant coming with a distinct name for its iterators. Span will soon need to define a borrowing iterator type; however, this work must be deferred until we have introduced that concept -- the addition should be done in that same proposal.)

glessard and others added 4 commits June 21, 2024 08:09
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 workgroup: blocked This proposal is blocked on some other consideration
Projects
None yet
7 participants