October 05, 2017 Iterating over functions in module in order? | ||||
---|---|---|---|---|
| ||||
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? |
October 06, 2017 Re: Iterating over functions in module in order? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jerry | 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 |
Copyright © 1999-2021 by the D Language Foundation