From: "Per Sandbergs" <prsa@cntw.com>
Subject: Re: is exception when others => null; smart?
Date: Thu, 24 Oct 2002 16:38:17 +0200
Date: 2002-10-24T16:38:17+02:00 [thread overview]
Message-ID: <tBTt9.1279$13.184@news1.bredband.com> (raw)
In-Reply-To: slrnarfvcc.4ud.randhol+news@kiuk0152.chembio.ntnu.no
Hi,
In general i find use of "when others => xxx" dumb especialy if xxx is null
since this as a general is ment to be a last resort
to catch unexpected events and report them.
My opinion about "when others => xxx" is that is may be used in the folowing
situations.
1)
main_loop:
loop
begin
lots of operations.
exception
when others =>
report the error and reset top a safe state in order to continue.
end loop;
2)
function work_is_ok(fool) return boolean is
begin
some computations
exception --
when others =>
return false; -- or report error and eventualt raise.
end;
2)
procedure must_not_raie(fool) is
begin
some computations
exception
when others =>
null;
end;
So when others => null is only to be used when you are expecting the
unexpected.
I wont be supprised if other peoplen are of different opinion but after
integration a number of large systems i find the above aproach "wise".
/Regards
/Per
"Preben Randhol" randhol+news@pvv.org wrote in message
news:slrnarfvcc.4ud.randhol+news@kiuk0152.chembio.ntnu.no...
> Hi
>
> As Emacs (ugg!) got installed when I had to reinstall Debian due to a
> hard disc crash, I thought I'd have a look at the ada-mode before
> uninstalling Emacs.
>
> Now I'm in the process of making a ada-mode for vim (currently called:
> am - Ada in the Morning) which will have much of the functionality of
> the ada-mode for Emacs.
>
> However there is one thing with ada-mode which I don't know is what I
> want:
>
> If you choose to generate a body for a procedure or a function then you
> get this:
>
> procedue Proc
> is
>
> begin
>
> exception
> when others => null;
> end Proc;
>
> My question is: Is this smart? I mean won't you then automatically mask
> all the potential problems you might get at run-time so that you won't
> see errors in the code during testing? I can see that it might also have
> advantages, but before I implement this I would like to hear what you
> think.
>
> Thanks in advance.
>
> Preben
> --
> Ada95 makes your code less cryptic.
>
next prev parent reply other threads:[~2002-10-24 14:38 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 [this message]
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 ` 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