|
|
|
|
|
by WalterBright
418 days ago
|
|
> the notion of a comptime variable (for which I couldn't find an analogue in D) A comptime variable in D would look like: enum v = foo(3);
Since an enum initialization is a ConstExpression, it's initialization must be evaluated at compile time.A comptime function parameter in D looks like: int mars(int x)(int y) { ... }
where the first parameter list consists of compile time parameters, and the second the runtime parameters.D does not have a switch-over-types statement, but the equivalent can be done with a sequence of static-if statements: static if (is(T == int)) { ... }
else static if (is(T == float)) { ... }
Static If is always evaluated at compile time. The IsExpression does pattern matching on types. |
|
This is one of the things that allow the "comptime language" to just be Zig, as in this example: https://ziglang.org/documentation/master/#Case-Study-print-i...