Do I need to use static here?

Machine Code jckj33 at
Tue Jan 8 18:35:51 UTC 2019

I'm using enum to compute the value at runtime like this:

struct A
	enum foo = A("foo", 10);
	enum baa = A("baa", 20);

	string name;
	int value;
	alias value this;

In order to avoid foo having its value (even if literal) copied 
every time A instancied and duplicates, shall I use static here?

I'm assuing that it works like this:

int f() {
    int a = 30;
    int b = 50;

and static would make it like this:

int f() {
   static int a = 20;
   static int b = 30;

int are examples, of course. I have A and array of A in my code.

More information about the Digitalmars-d-learn mailing list