|
|
|
|
|
by WalterBright
1118 days ago
|
|
In D, every part of the grammar that is a constant-expression must be compiled at compile time. For example: void test() {
int square(int y) { return y * y; }
int x = square(3); // evaluate at square at run time
enum y = square(3); // evaluate at square compile time
}
(Although, when the optimizer gets through inlining square(), etc., it will wind up at compile time anyway.) |
|