By scipio on Skatehive
Learn Zig Series (#14) - Generics with Comptime Parameters What will I learn You will learn how Zig implements generics using comptime parameters instead of template syntax; writing functions that accept comptime T: type for type-generic code; returning types from functions to build generic data structures; the @This() builtin for self-referential generic types; comptime type constraints and validation with @typeInfo; comptime duck typing with @hasDecl and @hasField; how std.ArrayList, std.HashMap, and std.BoundedArray use this pattern; monomorphization: each comptime instantiation generates specialized machine code; when generics add value vs when concrete types are simpler. Requirements A working modern computer running macOS, Windows or Ubuntu; An installed Zig 0.14+ distribution (download from ziglang.org); The ambition to learn Zig programming. Difficulty Intermediate Curriculum (of the Learn Zig Series): Zig Programming Tutorial - ep001 - Intro Learn Zig Series (#2) - Hello Zig,