zig icon indicating copy to clipboard operation
zig copied to clipboard

std: align PriorityQueue and ArrayList API-wise

Open matklad opened this issue 1 year ago • 5 comments

ArrayList uses items slice to store len initialized items, while PriorityQueue stores capacity potentially uninitialized items.

This is a surprising difference in the API that leads to bugs!

https://github.com/tigerbeetle/tigerbeetle/pull/1948

matklad avatar May 13 '24 14:05 matklad

Note: I haven't run the tests locally. I'd love to, but there's a conspicuous lack of a single command that I can just copy-paste to get the tests going at https://github.com/ziglang/zig/wiki/Contributing#testing, and I am not motivated enough at this point to extract that command from the overall build instructions :)

matklad avatar May 13 '24 14:05 matklad

Note: I haven't run the tests locally. I'd love to, but there's a conspicuous lack of a single command that I can just copy-paste to get the tests going at https://github.com/ziglang/zig/wiki/Contributing#testing, and I am not motivated enough at this point to extract that command from the overall build instructions :)

I'm... not sure I understand how there isn't a single easily copyable command to run the tests. It's at the top of the section you linked here. That aside, the first subsection has an even more easy-to-run local test that you can copy paste...

https://github.com/ziglang/zig/wiki/Contributing#directly-testing-the-standard-library-with-zig-test

mochalins avatar May 13 '24 14:05 mochalins

I have neither ./stage4/bin/zig nor zig in my path. I understand that I can spend time reading more docs about how to get those, but I am not motivated enough to do that, as, at this point, it's easier to just wait for CI

matklad avatar May 13 '24 15:05 matklad

@matklad just FYI, I don't think having zig in your PATH is required: zig abc xyz ... with zig in your PATH should yield the same result as specifying the full path as .../path-to-zig/zig abc xyz ... . (Just be sure with std testing to test the lib/std of the zig executable you're using, lest you accidentally mix two different versions, since import("std") will usually pick the one next to zig executable.)

rohlem avatar May 13 '24 17:05 rohlem

The problem is not PATH per se, but rather the fact that I don’t know which Zig I need (or, rather, which command I need to type to get the right zig without understanding which zig is right one).

To clarify, I know that I personally, if I spend time reading the docs, will be able to get the command to build/download the right version of Zig. I went through this exercise a couple of times already during the past year. It’s just that I remember that being non-trivial (the docs specify like five different ways to do this, and it’s unclear which one I need), and that I’ve already forgot what I’ve learned back then :-)

matklad avatar May 13 '24 19:05 matklad

Thanks! Great patch.

andrewrk avatar May 20 '24 16:05 andrewrk