Question Object.factory and namespaces.
dcoder
dcoder at nowhere.com
Thu Apr 12 07:11:11 PDT 2012
Hello.
I am reading through TDPL by Andresscu. The book has the
following example, which I am abbreviating:
void main( string[] args) {
Stat [] stats;
foreach( arg; args[1..$]) {
auto newStat = cast(Stat) Object.factory( "statsinc04." ~
arg);
enforce( newStat, "Invalid statistical function: " ~ arg);
stats ~= newStat;
}
My module is called statsinc04.d and you can see it listed above
in the foreach loop. My question is, how do I change the code
above so that it works even if I change the name of the
file/module? I'm looking for clean solution something like a
macro if one actually exists.
Thanks.
More information about the Digitalmars-d-learn
mailing list