comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <mcondic.auntie.spam@acm.org>
Subject: Re: In case statment? (was Re: is exception when others => null;smart?)
Date: Thu, 31 Oct 2002 07:40:20 -0500
Date: 2002-10-31T12:45:57+00:00	[thread overview]
Message-ID: <apr8m5$670$1@slb4.atl.mindspring.net> (raw)
In-Reply-To: 3DC04270.3060505@psu.edu

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 <rls19@psu.edu> 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
>






  reply	other threads:[~2002-10-31 12:40 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-24 14:03 is exception when others => null; smart? Preben Randhol
2002-10-24 14:25 ` David C. Hoos, Sr.
2002-10-24 14:28   ` Preben Randhol
2002-10-24 14:38 ` Per Sandbergs
2002-10-25 15:04   ` Robert A Duff
2002-10-25 20:41     ` Dale Stanbrough
2002-10-26 23:04       ` Robert A Duff
2002-10-26  7:47     ` tmoran
2002-10-24 16:39 ` Mark Biggar
2002-10-24 20:06   ` Robert A Duff
2002-10-24 20:23     ` Wes Groleau
2002-10-25  1:16       ` Jeffrey Carter
2002-10-25 10:10         ` In case statment? (was Re: is exception when others => null; smart?) Preben Randhol
2002-10-25 14:59           ` Robert A Duff
2002-10-25 15:06             ` Preben Randhol
2002-10-29 18:23             ` Peter Richtmyer
2002-10-30  2:52               ` Steven Deller
2002-10-30  8:58               ` Anders Wirzenius
2002-10-30 19:57                 ` Peter Richtmyer
2002-10-31  7:02                   ` Anders Wirzenius
2002-10-30  9:36               ` Lutz Donnerhacke
2002-10-30 19:44                 ` Peter Richtmyer
2002-10-30 13:28               ` Marin David Condic
2002-10-30 20:34                 ` Robert Spooner
2002-10-31 12:40                   ` Marin David Condic [this message]
2002-10-25 17:13           ` In case statment? <...> when others John Woodruff
2002-10-27 21:03           ` In case statment? (was Re: is exception when others => null; smart?) Ze Administrator
2002-10-28 10:04             ` Preben Randhol
2002-10-28 20:05               ` Wes Groleau
2002-10-30 11:31                 ` Preben Randhol
2002-10-28 12:32             ` In case statment? (was Re: is exception when others => null;smart?) Adrian Hoe
2002-10-24 20:11   ` is exception when others => null; smart? Simon Wright
2002-10-24 21:22     ` Larry Kilgallen
2002-10-24 20:03 ` Robert A Duff
2002-10-25  1:49 ` SteveD
2002-10-25  3:48 ` Dennis Lee Bieber
2002-10-26 11:34   ` Preben Randhol
replies disabled

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