Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Using Zig to Provide Stack Traces on Kernel Panic for a Bare Bones OS. Parent comment
For example you can do:
const std = @import("std"); fn Int(comptime value: i32) type { return struct { pub fn value() i32 { return value; } }; } pub fn main() anyerror!void { const int3 = Int(3); const int4 = Int(4); std.debug.warn("Types: {} {}\n", @typeName(int3), @typeName(int4)); std.debug.warn("Sum: {}\n", int3.value() + int4.value()); }
Types: Int(3) Int(4) Sum: 7
[2] https://godbolt.org/z/eLWeU2
[1] https://ziglang.org/documentation/master/#Generic-Data-Struc...
There are no comments on this comment yet.
For example you can do:
Output being: Edit: The compiler does the right thing:[2] https://godbolt.org/z/eLWeU2
[1] https://ziglang.org/documentation/master/#Generic-Data-Struc...