comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: In case statment? (was Re: is exception when others => null; smart?)
Date: Fri, 25 Oct 2002 14:59:41 GMT
Date: 2002-10-25T14:59:41+00:00	[thread overview]
Message-ID: <wccpttyk1ia.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: slrnari64a.pd.randhol+news@kiuk0152.chembio.ntnu.no

Preben Randhol <randhol+news@pvv.org> 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



  reply	other threads:[~2002-10-25 14:59 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 [this message]
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                   ` In case statment? (was Re: is exception when others => null;smart?) Marin David Condic
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