Skip to content

move types from builtin to std #3519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 24, 2019
Merged

move types from builtin to std #3519

merged 3 commits into from
Oct 24, 2019

Conversation

andrewrk
Copy link
Member

  • All the data types from @import("builtin") are moved to
    @import("std").builtin. The target-related types are moved
    to std.Target. This allows the data types to have methods, such as
    std.Target.current.isDarwin().
  • std.os.windows.subsystem is moved to
    std.Target.current.subsystem.
  • Remove the concept of the panic package from the compiler
    implementation. Instead, std.builtin.panic is always the panic
    function. It checks for @hasDecl(@import("root"), "panic"),
    or else provides a default implementation.

This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., std.builtin.Os (the enum type) from one
compilation and std.builtin.Os from another compilation are the same
type, even if the target OS value differs.

 * All the data types from `@import("builtin")` are moved to
  `@import("std").builtin`. The target-related types are moved
  to `std.Target`. This allows the data types to have methods, such as
  `std.Target.current.isDarwin()`.
 * `std.os.windows.subsystem` is moved to
   `std.Target.current.subsystem`.
 * Remove the concept of the panic package from the compiler
   implementation. Instead, `std.builtin.panic` is always the panic
   function. It checks for `@hasDecl(@import("root"), "panic")`,
   or else provides a default implementation.

This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
It had the downside of running all the comptime blocks and resolving
all the usingnamespaces of each system, when just trying to discover if
the current system is a particular one.

For Darwin, where it's nice to use `std.Target.current.isDarwin()`, this
demonstrates the utility that #425 would provide.
@andrewrk andrewrk merged commit 345042e into master Oct 24, 2019
@andrewrk andrewrk deleted the move-builtin-types branch October 24, 2019 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant