Skip to content

Add ability to determine if we are currently executing at compile time #868

Description

@tiehuis

I'm sure this was mentioned somewhere but could not find an issue: The gist is as follows:

if (@areWeInComptime()) {
   // use a slow fallback which we can compute in zig
} else {
   // use a fast runtime version that uses assembly (or features not supported at comptime)
}

This is present in D for example via the __ctfe variable. The current reason I need this is that I want to call sqrt at compile-time but on x86_64 this uses an assembly routine which can not be evaluated at compile-time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions