version(number) is completely useless
Walter Bright
newshound2 at digitalmars.com
Fri Jul 22 18:21:16 UTC 2022
On 7/22/2022 3:36 AM, Hipreme wrote:
> Okay, so what I asked is not exactly doing as people here thought like:
> ```d
> version(SDL > 2)
> ```
>
>
> What I asked is basically, for maintaining the same behaviour we have right now,
> when defining like SDL.2.5, it would define:
>
> ```d
> version(SDL.2.5) //Ok
> version(SDL.2.4) //Ok
> version(SDL.2.3) //Ok
> version(SDL.2.2) //Ok
> version(SDL.2.1) //Ok
> version(SDL.2.0) //Ok
> version(SDL.1.9) //Not ok
> ```
>
> It would basically just insert all possible versions when defining with a number
> like that, I'm not expecting to use those kind of operators with `version`.
I know, this is an 'OR' operation. My proposal is a better way of doing this.
> I have discussed and many people agree that doing many logical operators (besides
> `!version` (I do a lot of version(){}else{}) ) is bad.
!version is something I try to destroy. Versions should be positive
affirmations, not negative ones. For example,
version(DEMO) ... do demo stuff...
!version(DEMO) ... do release stuff ...
Better is to have `version(RELEASE)`. Even better, version the feature itself
that you're turning on.
Rationale: I've seen endless `#if CompilerVersion > 6` in C with all kinds of
versions, and the poor reader has no idea what features are being turned on and
off with them.
More information about the Digitalmars-d
mailing list