version(number) is completely useless
Andrey Zherikov
andrey.zherikov at gmail.com
Wed Jul 20 02:10:21 UTC 2022
On Wednesday, 20 July 2022 at 01:34:00 UTC, Steven Schveighoffer
wrote:
> On 7/19/22 9:22 PM, Andrey Zherikov wrote:
>> I actually have a question since this topic is brought up:
>> What is conceptual difference between `version(FOO)` and
>> `static if(FOO)`? I see `version` is a very limited comparing
>> to `static if` - the former checks for "boolean" result
>> (whether an ID is defined) while the latter evaluates
>> condition expression.
>
> version is specifically a replacement for #defines as in C.
> They are specified mostly on the command line.
It's not a full replacement because it doesn't support
`-DSOME_DEFINE=5` or `-DANOTHER_DEFINE="some string"`.
One of the features which I really miss in D is inability to do
these things. This is very largely used in software development
for setting compile-time constants from command line. D doesn't
support this out of the box (I have to dump a `.d` file with set
of `enums` and then include it into the build).
> But also, a version cannot be detected from an imported file --
> every module starts with the compilation versions, and that's
> it.
>
> Walter was very averse to the mess that is C preprocessor
> defines, and wanted something more hygienic.
I'm totally for simple and clean solution here but whatever D
offers right now is half-baked IMHO.
> The thing I miss the most for versions is a `version1 or
> version2` mechanism. I doubt we will ever convince Walter this
> is a good idea.
I don't think that `version1 or version2` is any different than
allowing complete conditional expression.
> But in any case, we have the numeric versions, which are 100%
> useless (because, as you say, they are not scoped to any
> dependencies), it would make sense to at least make that
> feature useful.
I don't see how raw numbers can be useful. Could you clarify your
idea?
More information about the Digitalmars-d
mailing list