All members of a package.d module using string lookup.

Ethan gooberman at gmail.com
Wed Aug 26 22:25:18 UTC 2020


I've got some weird juju during a DMD upgrade. The code I've 
posted below is representative of code that used to work for me 
to scrape for objects to bind with Binderoo when using package.d 
to make a folder a module. It has been working for a while. Now 
it doesn't.

And, weirdly, testing on godbolt with every compiler supported 
shows *it never should have worked*.

So. Using nothing but a module name as a string, what's the 
correct way to get all members when that module is a package.d 
implementation?

-----

https://run.dlang.io/is/VOWVoT

-----

template Alias( alias A )
{
	alias Alias = A;
}

template ModuleFromName( string strModuleName )
{
	mixin( "import " ~ strModuleName ~ "; alias ModuleFromName = 
Alias!( " ~ strModuleName ~ " );" );
}

alias StdRegex = ModuleFromName!"std.regex";

pragma( msg, StdRegex.stringof );
pragma( msg, "std.regex members: " ~ __traits( allMembers, 
StdRegex ).stringof );



More information about the Digitalmars-d mailing list