The others have already given some answers, I just want to point
out that the (free) sample chapter of my D book covers this topic
too:
http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book
Scanning a whole module and getting everything out takes a few
tricks that I
Hello,
I'm looking to introspect a module, list all the members, iterate
over them and filter them by kind inside of a static constructor.
This is in the hope of shortening some hand-written code that is
quite repetitive (adding many struct instances to an associative
array in a static
On Wed, 09 Jul 2014 20:07:56 +, NCrashed wrote:
On Wednesday, 9 July 2014 at 20:04:47 UTC, Maxime Chevalier-Boisvert
wrote:
auto members = [__traits(allMembers, ir.ir)];
pragma(msg, members);
Have you tried without quotes?
pragma(msg, __traits(allMembers, ir.ir));
Also, looks like it
On Wednesday, 9 July 2014 at 20:07:57 UTC, NCrashed wrote:
Produces:
ir/iir.d(85): Error: argument has no members
If module name is ir.iir: pragma(msg, __traits(allMembers,
ir.iir));
On Wednesday, 9 July 2014 at 20:07:57 UTC, NCrashed wrote:
On Wednesday, 9 July 2014 at 20:04:47 UTC, Maxime
Chevalier-Boisvert wrote:
auto members = [__traits(allMembers, ir.ir)];
pragma(msg, members);
Have you tried without quotes?
pragma(msg, __traits(allMembers, ir.ir));
Did need to
I got the following code to do what I want:
static this()
{
void addOp(ref Opcode op)
{
assert (
op.mnem !in iir,
duplicate op name ~ op.mnem
);
iir[op.mnem] = op;
}
foreach (memberName; __traits(allMembers, ir.ops))
{
On Wednesday, 9 July 2014 at 20:52:29 UTC, Maxime
Chevalier-Boisvert wrote:
It's a bit of a hack, but it works. Is there any way to create
some sort of alias for __traits(getMember, ir.ops, memberName)
so that I don't have to write it out in full twice? Made some
attempts but only got the