On 16 January 2012 23:19, Adam D. Ruppe <destructionator@gmail.com> wrote:
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.

The fact that everyone has their own work-around, and everyone has a DIFFERENT work around is hard evidence that version() is insufficient, and the current design is making D code WORSE.
Even Walter describes and supports the work-arounds to use in his poses from years ago.

I can see absolutely no evidence that performing logical expressions on versions is not required by any cross platform applications, including phobos! However now, instead of expressing the logic in a concise and familiar fashion, you have to try and decode each individuals own personal work-around scheme, at the expense of 10s of lines of really ugly spaghetti, and for absolutely no benefit.

There is hard evidence people can't work without version logic, so why continue to deny it?

Using '} else {' as a substitute for ! for example, you're STILL typing '!', you're just writing it in the ugliest and least intuitive way possible. Are people REALLY more likely to mis-read/misunderstand the '!' in the expression than miss the obscure 'else' statement to fake the same effect?
Using 'version(A) version(B)' as a substitute for &&... it's still &&, except it's way longer, and it's certainly not as clear that you're really performing a boolean &&. Why not just write what it is?
And ||, the MOST common operation to want to perform... let's not mention the work around, it's clearly the worst. Suffice to say, you're still producing OR logic, but again, writing it in a really archaic fashion.

People ARE writing these logical constructs whether they use a clear logical expressions or not... why not just let them write it between the parentheses in a clear and concise manner, than scatter and obscure the logic across 10 lines?