Predefined Versions for Apple Operating Systems
Quirin Schroll
qs.il.paperinik at gmail.com
Thu Jun 26 12:52:22 UTC 2025
On Sunday, 22 June 2025 at 00:44:42 UTC, Jonathan M Davis wrote:
> [I]f we were redoing them, maybe it would be better to just
> make them all of the predefined ones start with `__` so that
> any that start with `__` but aren't known are an error,
> significantly reducing the bugs related to mistyping version
> identifers - not that that would entirely fix the problem,
> since someone could still forget a `_` and make it look like a
> user-defined one (and of course, we can't fix the problem with
> user-defined ones unless we do something like require that a
> list of all valid version identifiers be provided somehow).
A different approach could be to special-case version identifiers
and require them to be ASCII-only and partially case-insensitive.
The latter means that `X` and `x` are considered essentially the
same, but only one of them is correct and defining it makes using
the other an error. That means the built-in ones `linux`,
`Windows`, `iOS`, etc., make it an error to use `Linux`,
`windows`, or `IOS`. The error message can tell you what the
correct spelling is. There’s no use case for the same identifier
with different casing. I’d also ban version user-defined version
identifiers with upper-case letters and reserve them for the
language.
Maybe also change all the built-in ones to include an upper case
letter.
It’s a breaking change, but one that can be mitigated by search
and replace.
```d
version(Linux) {} // error: Use `linux`
version(OSx) {} // error: Use `OSX`
version(Win) {} // error: `Win` is not a built-in version
identifier
version(win) {} // okay
```
More information about the Digitalmars-d
mailing list