-
Notifications
You must be signed in to change notification settings - Fork 9
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
Rename Alloc
to AllocRef
#8
Comments
Alloc
to AllocHandle
Alloc
to AllocHandle
IMO the main benefit here is that it clarifies the semantics of |
I hope this renaming would help clear some confusion that I’ve seen happen multiple times: “If Or: “Why does It turns out that Having vocabulary that separates “an allocator” and “a handle to that allocator” (and naming APIs accordingly) can hopefully make this indirection more discoverable. |
I strongly support this change. Just in discussing other issues over the last day or two there have been multiple times when I felt that calling it |
I think many will expect to be able to just write |
It should, actually, be possible to get something like |
Could you elaborate on this? |
You might consider something like the |
Basically what @SimonSapin says, but I want to expand on why it is not worth it to support this use case for an MVP. As @SimonSapin mentions, if the allocation storage lives within the We'd have to make those allocators If we wanted to support moving these, we'd need to support correcting this pointer on move. I don't see a way of achieving that without adding move constructors to the language, which would be a huge language change. So, AFAICT, we just can't support this right now, and the changes required to the language to support these are out-of-scope of this WG. |
This is a breaking change to an unstable API. Fixes rust-lang/wg-allocators#8 This change has some consensus. Landing it now will hopefully help clarify the vocabulary, including for discussion within the Allocators WG itself.
bikeshed: |
Has anyone found any drawback in renaming Personally, I like
Second, |
We rename For further explanation please see #8 (comment) and the comments after that one. The initial proposal was to rename The next step is review by the rest of the tagged wg members: No concerns currently listed. If you have any concerns regarding this change, please post those here. If you don't have the permissions to modify comments in this repository, please vote 👍 👎 instead. I will check the boxes for you then. |
cc @rust-lang/libs |
I'm so excited about our first FCP, that I already implemented this change, waiting for pressing the |
Rename `Alloc` to `AllocRef` The allocator-wg has decided to merge this change upstream in rust-lang/wg-allocators#8 (comment). This renames `Alloc` to `AllocRef` because types that implement `Alloc` are a reference, smart pointer, or ZSTs. It is not possible to have an allocator like `MyAlloc([u8; N])`, that owns the memory and also implements `Alloc`, since that would mean, that moving a `Vec<T, MyAlloc>` would need to correct the internal pointer, which is not possible as we don't have move constructors. For further explanation please see rust-lang/wg-allocators#8 (comment) and the comments after that one. Additionally it clarifies the semantics of `Clone` on an allocator. In the case of `AllocRef`, it is clear that the cloned handle still points to the same allocator instance, and that you can free data allocated from one handle with another handle. The initial proposal was to rename `Alloc` to `AllocHandle`, but `Ref` expresses the semantics better than `Handle`. Also, the only appearance of `Handle` in `std` are for windows specific resources, which might be confusing.
@TimDiekmann FYI, no need to include scott-maddox going forward. Please just tag scottjmaddox. Thanks! |
Rename `Alloc` to `AllocRef` The allocator-wg has decided to merge this change upstream in rust-lang/wg-allocators#8 (comment). This renames `Alloc` to `AllocRef` because types that implement `Alloc` are a reference, smart pointer, or ZSTs. It is not possible to have an allocator like `MyAlloc([u8; N])`, that owns the memory and also implements `Alloc`, since that would mean, that moving a `Vec<T, MyAlloc>` would need to correct the internal pointer, which is not possible as we don't have move constructors. For further explanation please see rust-lang/wg-allocators#8 (comment) and the comments after that one. Additionally it clarifies the semantics of `Clone` on an allocator. In the case of `AllocRef`, it is clear that the cloned handle still points to the same allocator instance, and that you can free data allocated from one handle with another handle. The initial proposal was to rename `Alloc` to `AllocHandle`, but `Ref` expresses the semantics better than `Handle`. Also, the only appearance of `Handle` in `std` are for windows specific resources, which might be confusing. Blocked on rust-lang/miri#1160
Merged in rust-lang/rust#68529 |
Nice work on the merged PR, @TimDiekmann! 👏🏻 Now that we have some momentum, what is the next step? |
Thanks! I'd favor splitting |
Build fails due to rust-lang/wg-allocators#8 being available on nightly rustc.
@SimonSapin suggested to rename
Alloc
toAllocHandle
in rust-lang/rust#58457 (comment):This would also apply to #9 and rename
Dealloc
toDeallocHandle
.Edit: Rename
AllocHandle
toAllocRef
as stated in #8 (comment)The text was updated successfully, but these errors were encountered: