Good examples of version() algebra in real code

Walter Bright newshound2 at digitalmars.com
Mon May 22 07:52:26 UTC 2023


I don't have links, it was a long time ago, but there was a time when someone 
introduced enums to druntime modules and used them with non-trivial static if 
expressions. People started extending this, and it soon became quite a tangle of 
some static ifs depending on other static ifs and the declarations of the enums 
became embedded in static ifs and then, inevitably, circular imports came into play.

Then, the whole thing reached a point where nobody could figure out whether 
particular static ifs were being triggered or not. The problem got dumped in my 
lap, and I yanked out all the static if's and replaced them with trivial logic.

In getting ImportC to work with system .h files, written by the best C experts 
on the planet, I've been re-acquainted with #ifdef hell.

I used to write #ifdef hell myself. It's very seductive.

So, yes, you can use static if and enums to implement version hell. But not in 
any official Dlang repositories.


More information about the Digitalmars-d mailing list