4 ms·
D guarantees that code that is an implementation of a constant-expression is evaluated at compile time. There really is no purpose to adding a keyword.
by WalterBright 2y ago
D guarantees that code that is an implementation of a constant-expression is evaluated at compile time.
There really is no purpose to adding a keyword.
- drjeats 2y agoIn the most common cases, Zig does exactly what D does here as well. Constant expressions are folded at compile time like any reasonable systems language. It's akin to writing C++ where you slap constexpr on everything. Zig agrees with D that constexpr is silly :) The one thing is Zig doesn't have D's notion of function purity, so I suspect there are cases where D could either infer that an expression is const where Zig can't, or at the very least D's compiler could do it faster. Not to dismiss D's contributions to systems programming languages, of course. Clearly a ton of inspiration of being pulled from y'all's work.