Code below is self explanatory.

Any assistance on how to get the line number is welcome ;-)


// ++++++++++++++++++++++++++

module test;

import std;

class myClass{ void foo(){}}

void myFunction1(){}

void main()
{
// list the first user defined member of this module (other than main)

    int i;
    foreach(m; __traits(allMembers, mixin(__MODULE__)))
    {
        // we can ignore these members
// "std" and "object" are created by the compiler, and "main" I'm not interested in.
        if(m == "std" || m == "object" || m == "main")
        {
            i = 1;
            continue;
        }

        writefln("The name of the first user member is: %s", m);

// On this next line, m.lineNumber is just a stub holder till an actual solution is found //writefln("The line number on which that member begins, is: %s, m.lineNumber);

        if(i == 1)
            break;
    }

    //writeln("Nothing to see here.");
}


void myFunction2(){}

// +++++++++++++++++++++++++

Reply via email to