Is there a doc page for the import("builtin") type/module?

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.

2 Likes

There is the --show-builtin option that allows you to look at the contents of import("builtin"):

2 Likes

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.

1 Like

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 like info.

  • @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 like impl or types.

6 Likes

clearly the code fairies added a .zig to the import when i wasnt looking to spite me, no other explanation :stuck_out_tongue:

2 Likes

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

3 Likes