How to create compile-time container?

Andrey Zherikov andrey.zherikov at
Tue Sep 1 19:05:53 UTC 2020

On Tuesday, 1 September 2020 at 18:19:55 UTC, Andrey Zherikov 
> The thing I'm trying to implement is: I have a function 
> foo(string s)() and some "state"; this function should override 
> this "state" (using "s" param) for all code within this 
> function (note that code can execute other modules that can 
> refer to the same "state"). The problem is that I need this 
> overridden "state" to be compile-time constant to be used in 
> mixin. Any ideas how I can do this?

In regular code it should look like this:

private string[] state;

string getCurrentState()
   return state[$-1];

void foo(string s)
   state ~= s;
   scope(exit) state = state[0..$-1];


More information about the Digitalmars-d-learn mailing list