Compile-time global mutables
bauss
jj_1337 at live.dk
Thu Jun 30 13:20:29 UTC 2022
On Thursday, 30 June 2022 at 13:16:48 UTC, Adam Ruppe wrote:
> On Thursday, 30 June 2022 at 12:26:54 UTC, HuskyNator wrote:
>> Essentially speaking, there are numerous instances in which
>> generating a list or incrementing a value is useful during
>> compile-time. I find this should be possible.
>
> What are those instances?
>
> The file example you showed is done with a perfectly normal
> constructor, it loads the file before moving on.
>
> If you want to collect a bunch of things and load them at once,
> you can use a module constructor; a `static this` in a
> template and the compiler adds them all together.
>
> Those module constructors can also increment normal runtime
> variables.
>
> I've done a lot of things in D and managed to get by never
> using a compile time counter...
Yeah, me too. The only time I have ever needed it was for
demonstrating concepts that were specific to the language and not
for any productive work.
More information about the Digitalmars-d
mailing list