www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - version and configuration

reply "Spacen Jasset" <spacen razemail.com> writes:
If I say this in one module:

version = current

version (Current) {
    version = featurea;
    version = featureb;
    version = featurec;
}

It appears that I can't put this in a module and import it 
elsewhere to test the version specifications as they are all in 
their own namespaces. Is this then a dead end for having a 
feature configuration file?

Is the way to do this to define some constants in a module, and 
test these instead. Something like:

features.d

featureA = true;
featureB = false;
--------------------------

main.d

import features;

static if (featureA == true) {

}
Sep 12 2015
next sibling parent "tcak" <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
On Saturday, 12 September 2015 at 14:41:45 UTC, Spacen Jasset 
wrote:
 If I say this in one module:

 version = current

 version (Current) {
    version = featurea;
    version = featureb;
    version = featurec;
 }

 It appears that I can't put this in a module and import it 
 elsewhere to test the version specifications as they are all in 
 their own namespaces. Is this then a dead end for having a 
 feature configuration file?

 Is the way to do this to define some constants in a module, and 
 test these instead. Something like:

 features.d

 featureA = true;
 featureB = false;
 --------------------------

 main.d

 import features;

 static if (featureA == true) {

 }
You can use enum to define featureA, featureB, and featureC instead of version. You could say, version(Current){ enum featureA = true; enum featureB = true; enum featureC = true; }
Sep 12 2015
prev sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 12 September 2015 at 14:41:45 UTC, Spacen Jasset
 It appears that I can't put this in a module and import it 
 elsewhere to test the version specifications as they are all in 
 their own namespaces. Is this then a dead end for having a 
 feature configuration file?
Correct, version doesn't get imported. You're better off using enums or ordinary variables.
Sep 12 2015