Skip to content

Zig

As of this writing, October 6 2023, the package manager is currently being worked on for the next release: 0.12.

Here are some relevant Github links detailing that work:

“To use a package that’s been prepared for the new Zig package manager, you just need to list it in the dependencies section.”

Zon. It uses files such as build.zig.zon which contains a zig anonymous struct. Example:

// because zon file is really just a zig struct
// comments are really done in the same way using 2 forward slashes
.{
// the name of your project
.name = "my-wtf-project",
// the version of your project
.version = "0.0.1",
// the actual packages you need as dependencies of your project
.dependencies = .{
// the name of the package
.zap = .{
// the url to the release of the module
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.7-pre.tar.gz",
// the hash of the module, this is not the checksum of the tarball
.hash = "1220002d24d73672fe8b1e39717c0671598acc8ec27b8af2e1caf623a4fd0ce0d1bd",
},
}
}
  1. run zig init-exe
  2. edit files
  3. zig build
  4. See dir zig-out/bin

TODO

TODO

For loops recently changed in Zig

const std = @import("std");
pub fn main() void {
const name = "Josey";
for (name, 0..) |char, i| {
_ = char;
std.debug.print("{c}\n", .{name[i]});
}
var elems = [_][]const u8{ "water", "earth", "fire", "air" };
var nats = [_][]const u8{ "tribes", "kingdom", "nation", "nomads" };
for (elems, nats) |e, n| {
std.debug.print("{s} {s}\n", .{ e, n });
}
}

Programming