What's the current state of the art for module compilation?

Walter Bright newshound2 at digitalmars.com
Sat Nov 28 23:44:37 UTC 2026


On 11/27/2026 12:40 PM, monkyyy wrote:
> Its possible to produce miscompiles with unchanging .d files given one of the 
> bugs that expose mutable compile time state, by which I dont mean only the 
> extermely useful compiler bug, but the useless ones that halt the compiler like 
> any of the template optimizations rikki did or `__traits(compiles` order of 
> operation bugs.
> 
> Since you may rudely remove features heres an acceptable lost: mixin("__LINE__") 
> with a -mixin flag gives different results based on how many mixin calls have 
> happened; if you were to use this int to change the order of a struct fields 
> reordering how you passed files to the compiler would give different results.
> 
> ```d
> struct vec2{
>    //mixin("static assert(1==1);");
>    static if(mixin("__LINE__")%2){
>      int x,y;
>    } else {
>      int y,x;
> }}
> ```
> 
> again using `-mixin=mix`; but .di files dont stand a chance in hostile examples, 
> the programmer must consider the order of operations of templates given complex 
> enough situations.

Fair enough. I do know that `static if` constructions that generate declarations 
need to be used with caution because of order-of-evaluation issues. The problems 
with this have been greatly reduced over time. I didn't eliminate the feature, 
though, because its value exceeded the cost.



More information about the Digitalmars-d mailing list