minwin

Walter Bright newshound at digitalmars.com
Tue Nov 28 23:36:42 PST 2006


Tomas Lindquist Olsen wrote:
> version(Windows || linux)
> {
>     ...
> }
> else
> {
>     ...
> }
> 
> is clearer IMHO.

That is certainly seductive and it's hard to see what's wrong with it. 
But I've seen what it inevitably leads to - an ugly, incomprehensible 
mess that is invariably wrong. It's often so bad that I have to run the 
preprocessor just to figure out which pieces of the code are actually 
being compiled! I haven't seen one yet that couldn't stand being 
reevaluated.

If you find wanting && and || and ?: and ! in the versions, I suggest 
one the following:

1) reevaluate just what feature it is you're testing for, and create a 
version identifier for that feature.

2) abstract the version differences away in a separate module.

Sure, it requires a little more work and a little more thought. But I 
think it's worth it, it's certainly been so when I've used that approach.



More information about the Digitalmars-d-announce mailing list