3 ms·
Thought I'd take a crack at it in Zig: const foo: [_][8]**fn () [*][*:0]const u8; This is an array of result-defined size, of arrays of eight pointers to
by samatman 2y ago
Thought I'd take a crack at it in Zig:
const foo: [_][8]**fn () [*][*:0]const u8;
This is an array of result-defined size, of arrays of eight pointers to fn pointers, which returns a many-item pointer to null-terminated arrays of u8. Null terminated because we're going to assume that the C data structure is properly null-terminated...
Still an insane data structure, and I'm still learning Zig, so I can't promise this is precisely equivalent to the C, I got as close as I could and am unwilling to try and compile, let alone build, such a type.
No one would actually do this unless they needed `extern` compatibility. Ignoring the fact (pointed out in the Fine Article) that no one would use anything vaguely like this, a more Zig native version might be
const foo: [_][8]**fn() [][]const u8
Which returns a slice of slices of immutable u8s, these being fat pointers which include their length.
- xigoi 2y agoNim equivalent: seq[array[8, ptr ptr proc(): ptr seq[ptr char]]]] I love having actual words instead of random punctuation soup.