version(number) is completely useless
Andrey Zherikov
andrey.zherikov at gmail.com
Wed Jul 20 01:16:20 UTC 2022
On Tuesday, 19 July 2022 at 22:30:28 UTC, Hipreme wrote:
> version(number) actually contains something really nice on it.
> But it is useless.
>
> For example: version(3) would actually declare version(2) and
> version(1).
IMO it is completely useless: what does "3" mean? what is
relationship between "3" in my package and "3" in dependency?
what is relationship between "3" in different sources within the
same package?
> The problem is that these doesn't mean anything at all, but
> they have this property of waterfall. Which is totally missing
> in D right now. Take this as an example:
>
> ```d
>
> version(V1_3)
> version = V1_2;
> version(V1_2)
> version = V1_1;
> version(V1_1)
> version = V1_0;
> ```
I don't like it - why can't we just write this instead?
```d
version(V1 >= 3)
pragma(msg, "newest version");
else version(V1 >= 2)
pragma(msg, "old version");
else
pragma(msg, "obsolete version");
```
But having this would mean that D has two ways to express the
same things: `version` and `static if` because that code is the
same as:
```d
static if(V1 >= 3)
pragma(msg, "newest version");
else static if(V1 >= 2)
pragma(msg, "old version");
else
pragma(msg, "obsolete version");
```
> I need to do this. **per file**. This is such a boilerplate
> code that could get a lot nicer if we had some kind of
> versioning syntax. For example `version(V.1.3)`. We could even
> get:
> `version(SDL.2.5)`. Which would declare everything down to
> SDL.2.0
Again, why can't it be `version(V >= 1.3)` or `static if(SDL >=
2.5)`?
More information about the Digitalmars-d
mailing list