On Monday, February 11, 2019 3:23:25 AM MST Seb via Digitalmars-d-learn wrote: > On Monday, 11 February 2019 at 09:29:13 UTC, Jonathan M Davis > > wrote: > > On Sunday, February 10, 2019 1:04:29 PM MST Per Nordlöw via > > > > Digitalmars-d- learn wrote: > >> [...] > > > > A quick grep of Phobos shows a version(DIP1000) block in > > std/typecons.d, which appears to be used to make it so that a > > particular unittest block is only compiled in when -dip1000 is > > used, so it looks like there's a version identifier for it. > > > > - Jonathan M Davis > > That one has been added manually: > > https://github.com/dlang/phobos/blob/master/dip1000.mak > > The detection would have been better...
Honestly, having an explicit version is far better than trying to detect it in an ad-hoc manner. It's actually guaranteed to be right in that case, whereas ad-hoc tests are more likely to have problems - especially if they're around for a while, and things change that weren't anticipated when the code was written. So, I'd actually argue that manually setting it as part of the build was a better idea than trying to detect it, but if it's manually set as part of the build instead of being built into the compiler, then it doesn't help anyone else. Though honestly, it seems to me that having version identifiers for transitional compiler flags like that is probably a good idea, since it makes transitioning code easier. The best that we can do otherwise is generally using __VERSION__, and that only works once the change is the default. - Jonathan M Davis