version()
Jonathan M Davis
jmdavisProg at gmx.com
Sun Jan 15 17:21:18 PST 2012
On Monday, January 16, 2012 01:14:32 Peter Alexander wrote:
> On 16/01/12 12:37 AM, Jonathan M Davis wrote:
> > Yes, right now. Everything that isn't Posix may be Windows, but that
> > won't necessarily always be true. So, when it comes to versioning, code
> > should definitely be versioned on what it _is_ rather than what it
> > _isn't_. But that doesn't preclude having&& and ||. It's just an
> > argument for disallowing !. And as you can see by my example, you can
> > essentially _already_ do ! thanks to else.
>
> I don't see why having '!' versioning is bad. It's perfectly reasonable
> to have things that happen in every version except one. For example, you
> might not want to run some code if running unittests. For that, using
> version(!unittest) would be ideal.
The problem is that when the code is then later compiled with a new version
(e.g. a new OS), it's using existing code for code which is already versioned
without it being checked. So, instead of the programmer checking each of the
relevant version blocks and making sure that the new version uses the
appropriate code (be it what's already there or new code), it just compiles
with then ! version. And if new code was needed for that code to work
correctly with the new version, then you have a bug, which you may or may not
catch.
Now, I don't deny that in some cases, being able to negate a version can be
quite useful. But it _can_ be a problem.
Ultimately, however, it's going to be up to the programmer to do the correct
thing. I don't think that not having && or || is necessarily helping all that
much in that regard. And since you can just use else, I'm not sure that
disallowing ! really helps either. And it _does_ cause problems for the people
who need more complex versioning.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list