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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no 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-31 04:45:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!newsflash.concordia.ca!snoopy.risq.qc.ca!newsfeed.news2me.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: In case statment? (was Re: is exception when others => null;smart?) Date: Thu, 31 Oct 2002 07:40:20 -0500 Organization: MindSpring Enterprises Message-ID: References: <3DB8204B.2080804@attbi.com> <3DB89B83.2060609@acm.org> <1b585154.0210291023.70af4929@posting.google.com> <3DC04270.3060505@psu.edu> NNTP-Posting-Host: d1.56.b0.f7 X-Server-Date: 31 Oct 2002 12:45:57 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Xref: archiver1.google.com comp.lang.ada:30252 Date: 2002-10-31T12:45:57+00:00 List-Id: True enough, but I don't think that really changes anything with respect to needing to look at your situation and see if it makes sense. A case statement might process *some* of the set of possible values & adding new enumerals can go to the default case. If it processes all of them and, while designing it, you think about what action you want it to take if anything new is added, you might have a proper accommodation. I would generally agree that if a case statement is intended to process all of a set of enumerals, avoiding "when others" helps you discover if you have a problem should the set expand. Its just that "never" is a very long time and engineers are wise to consider the unique circumstances around what they are building and use what works best for that situation. A blanket rule of "Never use 'when others'..." is a bad idea because sometimes it will make sense to do so. That's why I dislike blanket coding conventions. MDC -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jast.mil/ Send Replies To: m c o n d i c @ a c m . o r g "I'd trade it all for just a little more" -- Charles Montgomery Burns, [4F10] ====================================================================== Robert Spooner wrote in message news:3DC04270.3060505@psu.edu... > If you avoid using "when others" and a value is added to the enumeration > type later, the compiler will tell you where _all_ the case statements > using that enumeration type are so that you can examine them and see > what changes should be made. Then you don't have to spend a lot of time > using the debugger to crawl around in your code finding and fixing the > parts that don't work right. There's no guarantee that the default case > will be correct for a new value, and shifting errors from run time to > compile time is one of Ada's bigest advantages in my estimation. > > Bob >