Thoughts on std.system.OS

Jonathan M Davis jmdavisProg at gmx.com
Sat Aug 13 10:16:52 PDT 2011


On Saturday, August 13, 2011 14:49:13 Vladimir Panteleev wrote:
> On Sat, 13 Aug 2011 14:23:35 +0300, Jonathan M Davis <jmdavisProg at gmx.com>
> 
> wrote:
> > It does on at least some distros.
> 
> TIL...
> 
> > Except that you need useful, understandable version numbers to make
> > sense. 2.6
> > and 3.0 are virtually meaningless on Linux (which would be the major and
> > minor
> > number). Maybe the minor number will mean something with the 3 series,
> > but
> > we've had 2.6 for years now, and there's an enormous difference between
> > 2.6.3
> > and 2.6.33.
> 
> Perhaps make the version number a dynamic array?
> 
> > Even worse, major and minor numbers don't mean _anything_ on Windows.
> > What are
> > you going to give? The NT kernel version?
> 
> By the way, the Windows versions in the OS enum are very incomplete - only
> major client versions are listed.
> 
> A rather large variety of Windows versions and editions exists, see for
> example:
> 
> http://msdn.microsoft.com/en-us/library/ms724429(v=vs.85).aspx
> http://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
> 
> Considering the large variety, I think it would be a mistake to try to
> keep track of all Windows versions in an enum. I would like to suggest to
> replace all Windows versions in the OS enum with a single "Windows"
> entity, and add some constants or enums for common Windows versions to
> allow comparisons. For example:
> 
> if (os_major >  OS_MAJOR_WINDOWS_XP ||
>     (os_major == OS_MAJOR_WINDOWS_XP && os_minor >= OS_MINOR_WINDOWS_XP))
> {
>      // This is Windows XP or higher
> }
> 
> Going even further, a version structure supporting comparison operators
> would make the above simpler. (Or are regular dynamic arrays suitable for
> this?)

There are a large variety of Linux distros as well, and we can't cover all of 
them, so I'm not sure that the fact that there are lots of stray versions of 
Windows depending on how you count them merits handling Windows like that. 
However, it _is_ a bit odd to treat each version of Windows as a separate OS 
in the enum when none of the other OSes have more than one version in the 
list.

As for doing something like you suggest with the os_major and os_minor 
numbers, it does seem kind of messy. If all you want is comparison, you can do 
that with the existing enum, and it covers all of the Windows versions that 
most people will care about.

The situation definitely requires some consideration though. And it should 
probably be redesigned a bit.

- Jonathan M Davis


More information about the Digitalmars-d mailing list