Compile-time global mutables

Adam Ruppe destructionator at gmail.com
Thu Jun 30 13:16:48 UTC 2022


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...


More information about the Digitalmars-d mailing list