Fix factorial work distribution and update for Zig 0.16#3
Draft
mjackson wants to merge 3 commits into
Draft
Conversation
mjackson
commented
Apr 18, 2026
- Fix the factorial work distribution bug that returned a slice backed by stack memory and assumed a fixed 8-thread limit.
- Update the build script and command implementations for Zig 0.16's current build and stdlib APIs.
- Replace the temporary compatibility shim with direct Zig 0.16 I/O calls in the command modules.
There was a problem hiding this comment.
Pull request overview
Updates the ziglets CLI suite for Zig 0.16 APIs (notably the new std.Io I/O model and std.Build module setup) and addresses the factorial command’s work distribution implementation to avoid returning stack-backed slices / fixed thread limits.
Changes:
- Migrate command modules from
std.io.getStd*to Zig 0.16std.Ioreaders/writers. - Rework factorial work distribution to allocate thread ranges dynamically.
- Update
build.zigandmainentrypoint/arg handling to Zig 0.16 build + process init APIs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ziglets/writer.zig | Updates file I/O and stdout printing to Zig 0.16 std.Io APIs. |
| src/ziglets/touch.zig | Ports stdout + filesystem calls to std.Io APIs. |
| src/ziglets/pgen.zig | Ports stdout writer typing and updates RNG usage. |
| src/ziglets/guess.zig | Ports stdin/stdout I/O to Zig 0.16 std.Io interfaces. |
| src/ziglets/factorial.zig | Allocates work ranges dynamically and ports stdout to std.Io. |
| src/ziglets/clock.zig | Switches to std.Io.Clock and std.Io stdout writer usage. |
| src/ziglets/calculator.zig | Ports I/O to std.Io and updates raw-mode flag handling. |
| src/main.zig | Updates help output I/O and changes main signature + args parsing for Zig 0.16. |
| build.zig | Migrates to module-based addExecutable / addTest wiring for Zig 0.16. |
Comment on lines
+32
to
+35
| const n = try file_reader.interface.readSliceShort(buf); // Read the file content into the buffer, get the number of bytes read | ||
| var stdout_buffer: [0]u8 = undefined; | ||
| var stdout = std.Io.File.stdout().writer(io, &stdout_buffer); | ||
| try stdout.interface.print("file.txt content: {s}\n", .{buf[0..n]}); // Print the content of the file to standard output |
Comment on lines
+165
to
+169
| const io = std.Io.Threaded.global_single_threaded.io(); | ||
| var seed: u64 = undefined; | ||
| io.random(std.mem.asBytes(&seed)); | ||
| var prng = std.Random.DefaultPrng.init(seed); | ||
| const random = prng.random(); |
Comment on lines
120
to
+125
| // Leggiamo un singolo carattere (ora senza bisogno di premere Enter) | ||
| const bytes_read = stdin.read(&buf) catch |err| { | ||
| try stdout.print("\nError durante la lettura: {s}\n", .{@errorName(err)}); | ||
| return err; | ||
| const c = stdin.interface.takeByte() catch |err| switch (err) { | ||
| error.EndOfStream => return, | ||
| error.ReadFailed => { | ||
| try stdout.interface.print("\nError durante la lettura: {s}\n", .{@errorName(stdin.err.?)}); | ||
| return stdin.err.?; |
agreed Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.