Is D static if declarative or procedural?

Consider the following code:

static if (!is(MyStruct))
{
    struct MyStruct
    {
    }
}

static if (is(MyStruct))
{
    static assert(0);
}

My initial understanding was that the order of declarations (globally) does not matter in D.

However, in this case, the order static ifmakes the difference between compiling the program.

Is the step of evaluating the compilation time D, therefore, a procedural function (e.g. C / C ++), a declarative function, or something else? What is it now and what will it be (if they are different)?


Edit:

I just realized the problem here does not even end. What happens with static ifuses .tupleofto list members of the current module and create the same type of problems?

+5
2

, .

+2

. , , static if . , , , , , static if, static if , .

, . , , . , static assert. , static assert, static if, , . IMHO, . , - , , , static if, .

EDIT:

dmd:

; DMD , . "static if" "mixin" , - . , .

" if/mixin", ( ), , ( ).

, , .

+2

All Articles