From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f890526de6a8a218 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: How to detect OS type and version? Date: 15 Oct 2005 20:29:49 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <20051013115001.60b6a695@pscube.informatik.uni-stuttgart.de> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1129422589 21399 192.74.137.71 (16 Oct 2005 00:29:49 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 16 Oct 2005 00:29:49 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5712 Date: 2005-10-15T20:29:49-04:00 List-Id: Ray Blaak writes: > "Jeffrey R. Carter" 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