No need for version expression is a lie

Walter Bright newshound2 at digitalmars.com
Thu Aug 24 04:53:49 UTC 2023


On 8/23/2023 10:24 AM, Adam D Ruppe wrote:
> This kind of thing has happened even with Phobos.

Can you be more specific? I'm curious.


> D's `version` specifier is a major failure in real world code, leading to 
> incomprehensible soup in addition to runtime corruption, porting trouble, and 
> other problems.

C's #ifdef is not better in any way, and much much worse in many ways.

For library writers, there are indeed some things to watch out for. I recommend 
using the name of the library as a prefix on their version identifiers. For 
local versions, one can use private enums with static if.

Phobos has some head-scratchers, like this in std.stdio:

```
else version (CRuntime_DigitalMars)
{
     // Specific to the way Digital Mars C does stdio
     version = DIGITAL_MARS_STDIO;
}
```

https://github.com/dlang/phobos/pull/8802


More information about the Digitalmars-d mailing list