Good examples of version() algebra in real code
Dennis
dkorpel at gmail.com
Sun May 21 18:43:32 UTC 2023
D's version() statement deliberately does not allow composing
version conditions with boolean operators `! || &&`, in order to
avoid C's `#ifdef` hell. This is a controversial design decision
though, because some people don't like the resulting verbosity
you sometimes get. Discussions about this come up now and then,
see for example [Issue
7417](https://issues.dlang.org/show_bug.cgi?id=7417) and its
duplicates.
The most recent incarnation of this comes from this Phobos PR
proposing a library solution:
[std.compiler.Version](https://github.com/dlang/phobos/pull/8750)
```D
import std.compiler;
static if (Version.D_InlineAsm_X86 || Version.D_InlineAsm_X86_64)
{
version = UseX86Assembly;
}
```
I don't expect this to get approval though, I said in the PR
discussion:
> I'll bring this up in the next DLF monthly meeting, but without
> new compelling arguments, I don't expect a different outcome.
> If you can demonstrate problems (other than it not looking
> nice) in existing projects that the current logic causes,
> you'll have a stronger case.
So far I haven't received any real code examples, so I'm asking
here:
Do you have any examples of existing projects (on github, dub,
etc.) that either:
- demonstrate version algebra done well
- use a `Version`-like template successfully
- have real problems with existing `version()` statements
(besides 'it looks ugly')
Please reply with links and don't rekindle the old arguments. I
can't stop you, but know that it will only be counter-productive.
More information about the Digitalmars-d
mailing list