new discovery: import only if available

Adam D. Ruppe destructionator at gmail.com
Tue Jun 18 19:46:07 PDT 2013


whoa, I was just about go to bed, but turned the computer on 
because I just thought of one case where I think I want to do 
this: config files.

For my work apps, if I need config I always do them as a module:

config_a.d
===
module application.config;

enum featureA = true;
string appName = "Acme Software";
===


The selective module magic could be used to offer a default 
configuration, with the import overriding it if available:

static if(importIsAvailable!"app.config") {
    import app.config;
} else {
    enum featureA = false;
    string appName= "My App";
}

. That's potentially way cool.


More information about the Digitalmars-d mailing list