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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e4bb63e08046e1a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-29 10:23:19 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: prichtmyer@yahoo.com (Peter Richtmyer) Newsgroups: comp.lang.ada Subject: Re: In case statment? (was Re: is exception when others => null; smart?) Date: 29 Oct 2002 10:23:19 -0800 Organization: http://groups.google.com/ Message-ID: <1b585154.0210291023.70af4929@posting.google.com> References: <3DB8204B.2080804@attbi.com> <3DB89B83.2060609@acm.org> NNTP-Posting-Host: 164.223.72.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1035915799 2088 127.0.0.1 (29 Oct 2002 18:23:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 29 Oct 2002 18:23:19 GMT Xref: archiver1.google.com comp.lang.ada:30200 Date: 2002-10-29T18:23:19+00:00 List-Id: Robert A Duff wrote in message news:... > > "When others" is usually a very bad idea, and editors should not > encourage it. I find this topic somewhat amusing because my previous employer required a "when others" on ALL case statements, even when all values were covered by the "when" clauses. My current job requires us to specify all cases, and we are not allowed to put a "when others" clause in. As the following example illustrates, it really depends upon the compiler too. A "bad" value is handled differently as shown: ----------------------------------------------------------- with system; with text_io; procedure test is a : character := character'val(2#11111111#); for a'size use 8; b : boolean; for b'address use a'address; for b'size use 8; begin case b is when true => text_io.put_line ("b is true"); when false => text_io.put_line ("b is false"); when others => text_io.put_line ("ObjectAda for Windows V7.1.105 " & "professional " edition gets here, " & "and so does Rational Apex Ada 95 v. 4.0.0b"); end case; exception when others => text_io.put_line ("Gnat 3.14P gets here "); end test; ---------------------------------------------------------------