I somewhat rarely use version anymore. I used
to use it for different client customizations
to my app, but you can't turn features on and
off in a a central file like that, since the
version= doesn't affect other modules.

I switched for a while to static if like this:

version(client_a)
 enum feature_x = true;
version(client_b)
 enum feature_x = false;


== other file ==

static if(feature_x)
  void feature_x_impl() {}



But, now, I have a way of doing it without
version, and it's even better.


client_a_config.d:
===
module app.config;
enum feature_x = true;
===

client_b_config.d:
===
module app.config;
enum feature_x = false;
===


Real file:
===
import app.config;

static if(feature_x)
 // implement
===



Then, I pick the desired version just by picking
the file on the command line.


dmd app.d client_a_config.d # build client A's version
dmd app.d client_b_config.d # build client B's version



So, there's no version stuff in there at all... I now
think version is *almost* useless. Could probably use
this for operating system versions too, putting the
common components in a shared file.

Reply via email to