I got tired of waiting for a solution and rolled my own:



static this()
{

        import std.meta, std.stdio;

        // Find all <module>___This functions linked to this module
        auto Iterate()()
        {
                string[string] s;
                void Iterate2(alias m, int depth = 0)()
                {
                        static if (depth < 4)
                        {               
                                static foreach (symbol_name; 
__traits(allMembers, m))
                                {                       

                                        static if (symbol_name == "object") { }
                                        else static if (symbol_name == 
m.stringof[7..$]~"___This")
                                        {
                                                s[m.stringof[7..$]] = 
m.stringof[7..$]~"___This";
} else static if (isModule!(__traits(getMember, m, symbol_name)))
                                                {
                                                        
mixin("Iterate2!("~symbol_name~", depth + 1);");
                                                }
                                }
                        }
                }

                mixin("Iterate2!("~.stringof[7..$]~");");

                return s;
        }


        // Call all
        enum fs = Iterate;
        static foreach(k, f; fs)
                mixin(k~"."~f~"();");       
}


This code simply finds all <module>___This static functions linked to the module this static constructor is called from and executes them.

This doesn't solve the original problem but lets one execute the static functions to simulate static this. One could hypothetically even add attributes to allow for ordering(which is what the original cyclic redundancy check is suppose to solve but makes things worse since it is an ignorant algorithm).

This type of method might be more feasible, a sort of static main(). It does not check for static this of aggregates though but gets around the CRC's banket fatal error.


Reply via email to