minwin

Gregor Richards Richards at codu.org
Tue Nov 28 19:19:59 PST 2006


Walter Bright wrote:
> Bill Baxter wrote:
>> The bottom line is, just because D doesn't have negative version 
>> checks, doesn't mean the need for them will go away.  It just means that
>>   "version(X){}else"
>> becomes the spelling of "!version".  I'd personally rather see 
>> !version(X) or not_version(X) than version(X){}else.
> 
> Or perhaps rethink why there is a negative version called X in the first 
> place. For example, if you want:
> 
>     version (!FULL) { }
> 
> it would perhaps be better to redo the version as:
> 
>     version (EMPTY) { }
> 
> I've been through this with my own code, and it definitely improves the 
> readability to think in positive features rather than negative features. 
> Something about how human perception works. Long ago I read that there's 
> some research to back this up.
> 
> For example,
> 
>     version (NOFLOAT) => version (INTONLY)
version (BIGNUMONLY)
version (MATHUNSUPPORTED)
version (COMPLEXONLY)

>     version (NOTWINDOWS) => version (LINUX)

I hate to say this, but that example just plain stupid. All it will ever 
do is limit your code to work on only certain operating systems. That's 
hindering portability, and that's no good.

As it turns out, it's often the case that such-and-such does work on 
every sane operating system, and therefore version (!Windows) makes sense.

I know I've ran into instances where $WEIRD_SOCKET_FEATURE_X crashes 
horribly on a certain operating system, so I was forced to #ifndef 
__APPLE__. The same feature worked fine on literally every other system 
I tested it on, so it would be ridiculous to do an #ifdef for everything 
BUT Apple.

version (darwin)
version (BSD)
version (Solaris)
version (SkyOS)
version (DJGPP)
version (HURD)
version (ObscureOS)
version (OSYetToBeInvented)


Thinking in positives is great, but so unrealistic as to be completely 
valueless. version statements in reality are used like indexes into 
sets. The set of operating systems, the set of C libraries, the set of 
compielrs. And it's unrealistic and ignorant to try to index EVERY 
member except for whichever one you like, especially since the list is 
always growing.

Not everything has a positive opposite. In fact, most everything doesn't.

  - Gregor Richards



More information about the Digitalmars-d-announce mailing list