comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: How to detect OS type and version?
Date: 15 Oct 2005 20:29:49 -0400
Date: 2005-10-15T20:29:49-04:00	[thread overview]
Message-ID: <wcchdbigv7m.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: uek6m5nrg.fsf@STRIPCAPStelus.net

Ray Blaak <rAYblaaK@STRIPCAPStelus.net> writes:

> "Jeffrey R. Carter" <spam@spam.com> writes:
> 
> > Stefan Bellon wrote:
> > >    return "GNU/Linux";
> > 
> > Is there some reason you're using String rather than an enumerated type?
> 
> I submit that an enumerated type is the wrong thing to do. Operating systems
> are not fixed, can have many sub-variants. (WinOS, Win2000, WinNT, etc.).

Well, maybe, but...

> Simply adding a new OS to some central definition should not impact all
> existing code. In practical terms people should have had an "unknown OS"
> handler anyway.

What is the directory separator character on "unknown OS"?  ;-)

The advantage of using an enumeration type, and _not_ having an
Unknown_OS value, is that the compiler will tell you about all
the places you might need to change when you add a new OS.
That might or might not be what you want.

In my current project, I have two levels of distinction -- OS (Unix
vs. Windows, for example) and OS_Flavor (Solaris vs. Linux, for
example).  I've not needed to distinguish (for example) different
versions of Linux, and it's probably a good idea to avoid that fine
level of distinction if possible.

> It's akin to having some app that processes first names as enumerated values
> instead of strings. It's a mistake because the set of values are open ended
> and are not known in advance, and can change depending on where you execute.

You probably don't port to a new OS quite as often as you add names to
your database of telephone numbers or whatever.  And you probably don't
use wildly different code based on first names, which needs updating
every time you add a new first name.

- Bob



  reply	other threads:[~2005-10-16  0:29 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13  2:35 How to detect OS type and version? Roger Blum
2005-10-13  6:05 ` Martin Dowie
2005-10-13  9:50   ` Stefan Bellon
2005-10-13 10:39     ` Martin Dowie
2005-10-13 18:12     ` Jeffrey R. Carter
2005-10-13 18:37       ` Stefan Bellon
2005-10-13 21:21         ` Robert A Duff
2005-10-13 21:25           ` Stefan Bellon
2005-10-13 21:52             ` Robert A Duff
2005-10-16  0:13       ` Ray Blaak
2005-10-16  0:29         ` Robert A Duff [this message]
2005-10-16  4:48           ` Ray Blaak
2005-10-16 14:16             ` Larry Kilgallen
2005-10-16 15:55               ` Robert A Duff
2005-10-16 20:06               ` Pascal Obry
2005-10-18 16:58                 ` Ray Blaak
2005-10-16 15:59             ` Robert A Duff
2005-10-17 17:19               ` Ray Blaak
2005-10-13 18:11   ` Jeffrey R. Carter
2005-10-13 19:44   ` Simon Wright
2005-10-13 21:04   ` Michael Bode
2005-10-14  1:33     ` Steve
2005-10-13 12:06 ` Rob Norris
2005-10-13 11:59   ` Martin Dowie
2005-10-14  0:21     ` Randy Brukardt
2005-10-14  8:02       ` Martin Dowie
2005-10-14 23:27         ` Randy Brukardt
2005-10-15 12:28           ` Larry Kilgallen
2005-10-15 14:12             ` Martin Dowie
2005-10-14  9:52     ` Rob Norris
2005-10-13 20:25 ` Bernd Specht
2005-10-13 20:36   ` Michael Bode
2005-10-13 20:41     ` Bernd Specht
2005-10-13 20:58       ` Stefan Bellon
2005-10-14  0:27         ` Randy Brukardt
2005-10-15 19:48           ` Bernd Specht
2005-10-14  6:30 ` Roger Blum
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox