version(number) is completely useless

Steven Schveighoffer schveiguy at gmail.com
Wed Jul 20 01:34:00 UTC 2022


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.

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.

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.

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.

-Steve


More information about the Digitalmars-d mailing list