Skip to content

Conversation

andrewrk
Copy link
Member

As a nice little bonus, the namespaces no longer have any redundancies.

Upgrade Guide

  • std.ArrayList -> std.array_list.Managed
    • warning: will be eventually removed from standard library
  • std.ArrayListAligned -> std.array_list.AlignedManaged
    • warning: will be eventually removed from standard library

@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. release notes This PR should be mentioned in the release notes. labels Aug 11, 2025
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`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// slice of `T` values. Initialize with `init`.
/// slice of `T` values.

nothing else needed as the lines below say how you should actually inititalize

Copy link
Contributor

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

Copy link
Member

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?

@AndrewKraevskii
Copy link
Contributor

Since its breaking change wouldn't it also make sense to remove default field values?

@andrewrk
Copy link
Member Author

Tested locally with stage3/bin/zig build test -Dskip-release -Dskip-non-native

@andrewrk andrewrk merged commit 749f10a into master Aug 11, 2025
4 of 14 checks passed
@andrewrk andrewrk deleted the unmanaged branch August 11, 2025 22:52
DialecticalMaterialist added a commit to DialecticalMaterialist/zls that referenced this pull request Aug 12, 2025
arrufat added a commit to bfactory-ai/zignal that referenced this pull request Aug 14, 2025
arrufat added a commit to bfactory-ai/zignal that referenced this pull request Aug 14, 2025
@MahdiGMK
Copy link

why are we removing managed containers? what pattern do unmanaged containers allow that managed ones dont?

MahdiGMK added a commit to MahdiGMK/nanovg-zig that referenced this pull request Aug 17, 2025
@andrewrk
Copy link
Member Author

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?

  • avoiding accidentally using the wrong allocator
  • convenience when you need to pass an allocator also

But there are downsides:

  • worse method function signatures in the face of reservations
  • lost inability to statically initialize
  • extra memory storage cost, particularly for nested containers

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.

@Fincap
Copy link

Fincap commented Aug 23, 2025

Are there any plans on changing the other std containers to fit this new pattern?

  • std.ArrayList -> std.array_list.Managed
  • std.ArrayListAligned -> std.array_list.AlignedManaged
  • std.HashMap -> std.hash_map.Managed
  • std.AutoHashMap -> std.hash_map.AutoManaged
  • std.StringHashMap -> std.hash_map.StringManaged
  • std.ArrayHashMap -> std.array_hash_map.Managed
  • std.AutoArrayHashMap -> std.std_array_hash_map.AutoManaged
  • std.StringArrayHashMap -> std.std_array_hash_map.StringManaged
  • std.DynamicBitSet -> std.bit_set.DynamicManaged

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.

@andrewrk
Copy link
Member Author

Yes, all of them.

fabioarnold pushed a commit to fabioarnold/nanovg-zig that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Implementing this issue could cause existing code to no longer compile or have different behavior. release notes This PR should be mentioned in the release notes. standard library This issue involves writing Zig code for the standard library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants