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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e4bb63e08046e1a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-25 08:00:51 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!newshosting.com!news-xfer1.atl.newshosting.com!news2.euro.net!uunet!ash.uu.net!world!news From: Robert A Duff Subject: Re: In case statment? (was Re: is exception when others => null; smart?) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Fri, 25 Oct 2002 14:59:41 GMT Content-Type: text/plain; charset=us-ascii References: <3DB8204B.2080804@attbi.com> <3DB89B83.2060609@acm.org> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:30132 Date: 2002-10-25T14:59:41+00:00 List-Id: Preben Randhol writes: > Now my next question is should a case statment be: > > case Number is > > when others => > null; > end case; > > Or simply: > > case Number is > > end case; > > I'm leaning towards the latter as this is also how ada-mode does it. "When others" is usually a very bad idea, and editors should not encourage it. One of the great benefits of Ada is the full-coverage checking you get (at compile time!) on case statements and aggregates. (Compared to other languages which default to "when others => null;" or use run-time checking.) Some folks think "when others" is just a shorthand for all the rest of the enumeration literals (or whatever) in the type, that you don't feel like typing in. After all, that's what the RM says. But I think "when others" really means "all the others, INCLUDING the ones that will be invented next week or next year". So you should use "when others" only when you're pretty sure all the others that will ever be invented must necessarily fall into the same category. That's rare. So I agree: choose the latter. - Bob