Comment

Comment by WalterBright

D uses `enum` to specify a manifest constant, which evaluates at compile time:

    int i = f(3); // evaluate at run time
    enum i = f(3); // evaluate at compile time
Note that it's not the function that is specified as being run at compile time, it is the use of the function that determines it. There is no difference between compile time functions and runtime functions. The use that triggers a function to be evaluated at compile time is when the function call is in a const-expression.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton