btw: Zig has three distinct concepts involving the term “builtin”: builtin functions, the import("builtin")
module, and the import("std").builtin
module. While not a major issue, this overlap can be slightly confusing for learners new to Zig.
There is the --show-builtin
option that allows you to look at the contents of import("builtin")
:
I agree the 3 “builtins” is confusing. I don’t think there is a way to view docs for import("builtin")
, as that file is specific to the target machine (IIRC). But I have had success with zls and “go to definition” to view the file.
std.builtin
is @import("builtin")
That’s the confusing part – they are different:
-
@import("builtin")
is a module with current compilation details that is automatically generated and exposed to the user code. Should probably be called smth likeinfo
. -
@import("std").builtin
is a standard library namespace with type definitions that are used by the compiler backends as well as exposed to the user code. Should probably be called smth likeimpl
ortypes
.
clearly the code fairies added a .zig
to the import when i wasnt looking to spite me, no other explanation
Oh, dear, I remember being massively confused about this as well. Yeah, it feels like it’s best to move std.builtin.Type
and friends elsewhere. std.zig.Type
reads nice, though it muddies the water as to what’s unstable and what’s very unstable in std.m