version and debug statements
Walter Bright
newshound at digitalmars.com
Thu May 11 15:41:03 PDT 2006
pragma wrote:
> Walter, I mean no disrespect here, but I simply must ask: Are you talking about
> a literal interpretation of version() and debug(), including the lack of an
> #ifndef equivalent?
>
> Like this:
>
> #ifdef FOOBAR
> #else
> /*** code ***/
> #endif
>
> Or like this (using ifndef):
>
> #ifndef FOOBAR
> /*** code ***/
> #endif
>
> I don't think that version() and debug() need to be tangled up with all kinds of
> boolean expressions, but maybe a short-and-sweet concession to allow an
> equivalent to #ifndef is in order? Sure its just "one line more readable" but
> it *is* more readable after all.
Consider another perspective: when a version of the code is being built,
one thinks about a version being build, not a "not version". If you find
that you're writing:
version (FOOBAR)
else
{
...
}
I suggest that perhaps FOOBAR is the wrong name for the version being
compiled. For example, I would red flag code that looked like:
version (Windows)
else
{
...
}
I also have a particular dislike for the execrable double negative style
often seen in C:
#ifndef NO_FOO
...
#endif
There is some psychobabble research on this, suggesting that people tend
to skip nots, and even more often miss double negatives. I know that in
airplane pilot jargon, considerable effort has been made to purge
negations and replace them with positive statements, as they are less
prone to misinterpretation.
Some more examples:
1) Don't build a "NOTFULL" version, build a "DEMO" version.
2) Don't build a "NOTDEMO" version, build a "FULL" version.
3) Don't build a "NOHARDTABS" version, build a "SOFTTABS" version.
etc. If there are some specifics cases you feel just don't fit with
this, can you post them?
More information about the Digitalmars-d
mailing list