-
-
Notifications
You must be signed in to change notification settings - Fork 3k
std.ArrayList: make unmanaged the default #24801
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
Conversation
lib/std/std.zig
Outdated
pub const Uri = @import("Uri.zig"); | ||
|
||
/// A contiguous, growable list of items in memory. This is a wrapper around a | ||
/// slice of `T` values. Initialize with `init`. |
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.
/// slice of `T` values. Initialize with `init`. | |
/// slice of `T` values. |
nothing else needed as the lines below say how you should actually inititalize
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.
Also init
just doesn't exist on ArrayList
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.
yes, that's why i made this suggestion?
Since its breaking change wouldn't it also make sense to remove default field values? |
Tested locally with |
why are we removing managed containers? what pattern do unmanaged containers allow that managed ones dont? |
It's the other way around. Having an extra field is more complicated than not having an extra field, so not having it is the null hypothesis. What pattern does having an allocator field allow that not having one doesn't?
But there are downsides:
The reasoning goes like this: the upsides are not worth the downsides. Also, given that the correct allocator is always handy, and incorrect use can be trivially safety-checked, the simplicity of only having one implementation is quite valuable compared to the convenience that is gained by having a second implementation. In practice, this has not been a controversial change with experienced Zig users. |
Are there any plans on changing the other std containers to fit this new pattern?
Apologies in advance if this has been answered in another PR/issue, my searches have turned up nothing. I can move this into its own issue if this would be more appropriately placed there. |
Yes, all of them. |
As a nice little bonus, the namespaces no longer have any redundancies.
Upgrade Guide
std.ArrayList
->std.array_list.Managed
std.ArrayListAligned
->std.array_list.AlignedManaged