No need for version expression is a lie
Adam D Ruppe
destructionator at gmail.com
Thu Aug 24 18:54:03 UTC 2023
On Thursday, 24 August 2023 at 16:47:55 UTC, Walter Bright wrote:
> That was something different.
No, it is a case of the same general problem. It even literally
uses the `version` keyword in the language!
The best advice I have is to never use any version specifier
except the built in platform ones. `version(Windows)` is not
great but not demonstrably harmful the way user-defined versions
or `version(unittest)` and others influenced by build flags are
just because those are *so* easy to get out of sync. And
`version(unittest)` is actually extraordinarily dangerous because
`unittest` is so generic.
At least `version(no_fork)`, while it could be defined by
multiple libraries in differing ways, is somewhat unlikely to be
seen. But virtually all D code agrees on `unittest` being a
condition they use since it is actually standardized.
This would be mitigated if the -unittest switch took a module
pattern. -version taking a module pattern would help limit its
damage. You'd still want to match when building, but at least
then it would be intentionally namespaced and avoid accidental
conflicts.
> I wouldn't set it up that way. I'd version on IA64 within
> CRuntime_DigitalMars. I.e. overlapping version declarations are
> not a good plan, for precisely the reason you mention. Better
> to version along orthogonal axes.
https://dlang.org/spec/version.html#predefined-versions
Plenty of overlapping things in that existing list.
(and i expect you meant X86_64 rather than IA64, but that falls
apart if it ran on AArch64 too, so that'd be all the more reason
to have a separately defined thing like Phobos did)
> It failed because none of them had ever ported code from 16 to
> 32 before, and so the future-proof solutions were all the wrong
> solutions.
Indeed. Just like with D's `version` feature, it seemed like a
good idea at the time, but didn't stand up to real world use in
the long run.
> At some point, you're just going to have to run:
>
> grep -r version *
The problem with this is that `-version` is global, including
across dependencies of dependencies that might not even be in
tree.
More information about the Digitalmars-d
mailing list