On Sunday, 23 March 2014 at 12:28:06 UTC, Phil wrote:
On Sunday, 23 March 2014 at 12:20:51 UTC, Phil wrote:
Is it possible to enumerate all functions in a module? I'd like my test program to find the functions in a fibrary with a particular attribute defined, but I can't find any way to do this. I've looked in std.traits; maybe I'm missing something.

Ah, allMembers does the trick. Probably could have spent a bit longer googling that one before posting!

Well I just made this for you, so here it is anyway:

module mymodule;
import std.stdio : writeln;

void main() {
        foreach(m; __traits(allMembers, mymodule)) {
static if (__traits(isStaticFunction, __traits(getMember, mymodule, m))) {
                        writeln(m);     
                }
        }
}

void myfunc() {
}

Output:

main
myfunc

Reply via email to