Once upon a time, the current operating system was identified and conditioned on via @<os>_only macros. Eventually these were replaced with is_<os> functions in #16219. However, these 5 functions differ from the rest of Base in that there are 74 Base functions that begin with is and only 6 (including these 5) that begin with is_. (In case you're wondering, the one other misfit is is_assigned_char.) This is a very unfortunate inconsistency. Thus I opened #22182 to rename these to match the rest of Base. That is, is_<os> -> is<os>.
A discussion started up in that PR regarding an alternative way to identify and condition on operating systems. In particular, one idea was to define separate types for each operating system, with subtyping to show that a given OS is Unix-based, for example. I made a prototype of this in OperatingSystems.jl.
Now, the purpose of this issue is to discuss the possibility of an alternative design, should we decide it's worth the churn. As I've said in #22182, the only change I think is necessary is to remove the underscore, but I figured it's worth having a wider discussion on how best to address this.
The hierarchy approach in OperatingSystems.jl is pretty nice. I can even see writing dispatch-based code for certain system-specific things.
One example that comes to mind for dispatching on the OS is BinDeps.
Even if we add os() <: OS.Windows in Base, I would still like the simplicity of iswindows(), since this is a pretty common check.
One option on this front would be to keep the iswindows() family of functions, but implement them as, e.g.
iswindows() = Sys.OS <: Sys.Windows
That provides a concise way to condition on the OS inside of functions or programs while at the same time allowing a hierarchical type-based approach that can be used for dispatch purposes.
Does that seem like a good idea, or would it be bad to have two ways of expressing the same thing?
Feels over-designed to me
Fair point. What's your preference, @vtjnash? Just iswindows()?
Most helpful comment
Even if we add
os() <: OS.Windowsin Base, I would still like the simplicity ofiswindows(), since this is a pretty common check.