On 11/12/21 11:00 PM, forkit wrote:

> // nope. writes the line no. of the foreach loop

mixin(m) seems to solve the issue, which I think necessitates 'static if':

    static foreach(m; __traits(allMembers, mixin(__MODULE__)))
    {
        static if(m == "std" || m == "object" || m == "main")
        {
          // Ignore
        } else {
          writefln("The name of the first user member is: %s", m);
          writeln(__traits(getLocation, mixin(m))[1]);  // <-- HERE
        }
    }

It works because we mix-in the value of the string 'm', which becomes a symbol.

('foreach' instead of 'static foreach' works as well.)

Ali

Reply via email to