www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Iterating over functions in module in order?

reply Jerry <hurricane hereiam.com> writes:
Any ideas on how someone could iterate over functions in a module 
as they appear, rather than any random order, without having to 
manually label them?
Oct 04
parent Alex <sascha.orlov gmail.com> writes:
On Thursday, 5 October 2017 at 00:24:12 UTC, Jerry wrote:
 Any ideas on how someone could iterate over functions in a 
 module as they appear, rather than any random order, without 
 having to manually label them?
Do you mean something like this? /// --- code --- module test165; import std.stdio; import std.traits : isFunction; void main() { immutable b = [ __traits(allMembers, mixin(__MODULE__)) ]; static foreach(i, _; b) static if(isFunction!(__traits(getMember, mixin(__MODULE__), b[i]))) writeln(b[i]); } auto fun1(){} struct S; int i; double[] arr; auto fun3(int val){} auto fun2(T)(T notAfun) {} /// --- code --- I saw a similar problem here: http://forum.dlang.org/post/xratcdpxfepxowghjyxd forum.dlang.org
Oct 06