No need for version expression is a lie

Walter Bright newshound2 at digitalmars.com
Thu Aug 24 17:03:20 UTC 2023


On 8/24/2023 8:30 AM, Adam D Ruppe wrote:
> Or when someone again tries to figure proof and puts `else static assert(0)` at 
> the end, making incremental porting impossible. (which i also wrote about in the 
> last year: 
> http://dpldocs.info/this-week-in-d/Blog.Posted_2023_02_20.html#static-assert-patterns-arguably-harmful-for-porting )

Not impossible, just initially a mite tedious. One can still incrementally port 
to AdrOS by adding:

```
version (Windows)
{
      enum x = 7;
}
else version (AdrOS)
{
      enum x = 0; // FIXME
}
else
      static assert(0);
```

and at least the compiler will tell you were all these places are. Then, a grep 
for FIXME will find every place you overlooked.

You wrote that this is in hundreds of places in druntime. Great! If this 
technique wasn't used, I guarantee that any port to AdrOS will miss more than a 
few, and it will be hell to figure out what is going wrong. I guarantee it 
because it always happened when defaults were used for unknown systems.

I prefer a bit of tedium to debugging hell.

This is also why the `default` case is required for D switches.




More information about the Digitalmars-d mailing list