Zig
Using Zig 0.11 in 2023
Section titled “Using Zig 0.11 in 2023”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:
- https://github.com/ziglang/zig/pull/17392
- https://github.com/ziglang/zig/issues/14298
- https://github.com/ziglang/zig/pull/17277
- https://github.com/ziglang/zig/pull/14603
“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", }, }}- run
zig init-exe - edit files
zig build- See dir
zig-out/bin
Zig concurrency
Section titled “Zig concurrency”TODO
Zig Memory alocation
Section titled “Zig Memory alocation”TODO
For loops
Section titled “For loops”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 }); }}