Is it possible to add items to the arrays and hashes at compile time?
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 10 10:00:32 PDT 2015
On Wednesday, 10 June 2015 at 07:15:26 UTC, Ali Çehreli wrote:
> My phrasing was off: By definition, initialization happens
> once. :) What I meant is, once initialized, a compile-time
> variable cannot be reassigned. The reason is, to effect compile
> time evaluation, one needs to use 'enum' (or 'static const')
> but 'enum' is a literal, i.e. it cannot be modified.
>
> As I've shown, it is possible to use an expression that will be
> used as the value of the compile-time variable. As long as it
> is evaluable at compile time, the expression can be arbitrarily
> complex.
I understand your phrase :) I don't understand why the variables
at compile time cannot be reassigned. I.e. why can't we use `int`
instead of `enum` or `immutable`? Isnt it possible to come up
with the interpreter compile-time, which will determine the
operating time of the program at runtime at compile time. And if
this time is small, it is possible to reassign variables at
compile time more than once. Maybe it's something out of science
fiction, but still. Is it possible somehow to create a more
complex compilation process, which can reassign variables more
than once?
More information about the Digitalmars-d-learn
mailing list