Thoughts on std.system.OS

Vladimir Panteleev vladimir at thecybershadow.net
Sat Aug 13 04:49:13 PDT 2011


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?)

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d mailing list