comp.lang.ada
 help / color / mirror / Atom feed
From: Ehud Lamm <mslamm@mscc.huji.ac.il>
Subject: Re: Exception Handling
Date: 2000/06/01
Date: 2000-06-01T19:16:30+00:00	[thread overview]
Message-ID: <Pine.A41.3.96-heb-2.07.1000601221032.22704B-100000@pluto.mscc.huji.ac.il> (raw)
In-Reply-To: slrn8jccst.232.randhol+nospam@kiuk0156.chembio.ntnu.no

On 1 Jun 2000, Preben Randhol wrote:

|Would it be OK to trap an erronious entry (like "2.3W-4") with an
|exception or would you make an extra check before trying to convert the
|string to a float (or the appropriate class).
|
|The reason I'm asking is that there seems to be two "camps" those who
|use exceptions extensivly and those who use it far less. I'm trying to
|find the border when and when not to use exceptions.
|

The way I see it, it's like this. I try not to use exceptions to guide the
flow inside a routine (like "goto") unless there is a good reason to do so
(e..g, if there is convergence with an exception raised by a service
routine etc.).

So if I am doing a translation myself (char by char) I'd probably use an
"if" (though I am not 100% sue, since you should always check the
complexity things add to your code. If it is simply if s(i) is digits ...
elsif upcase(s(i))='E' ... else ERROR than I can live with that).
If I can use another routine to do the conversion, I'd assume the routine
would communicate the presence of an error with an exception.

Since I assume the input routine is an input routine, and thus wrog input
is problematic, I'd think the input routine itself RAISES an exception.
(This is the other side of the coin...)

You can see an possible approach to these issues (though not exactly
matching your scenario) in my Safe_Io package, and my Generic_Menu
routine. Both on AdaPower.

Ehud Lamm mslamm@mscc.huji.ac.il
http://purl.oclc.org/NET/ehudlamm <== My home on the web 
Check it out and subscribe to the E-List- for interesting essays and more!







  parent reply	other threads:[~2000-06-01  0:00 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-29  0:00 Exception Handling NANCY HEHIR
2000-05-29  0:00 ` Preben Randhol
2000-05-30  0:00 ` Robert Dewar
2000-05-30  0:00 ` Jeffrey D. Cherry
2000-05-30  0:00   ` Gautier
2000-06-05  0:00     ` Robert Dewar
2000-06-01  0:00   ` Preben Randhol
2000-06-01  0:00     ` Preben Randhol
2000-06-01  0:00     ` Ehud Lamm [this message]
2000-06-01  0:00     ` Jeffrey D. Cherry
2000-06-02  0:00       ` David C. Hoos, Sr.
2000-06-02  0:00         ` Jeffrey D. Cherry
2000-06-01  0:00     ` Jeff Carter
2000-06-02  0:00       ` Jeffrey D. Cherry
2000-06-02  0:00       ` Preben Randhol
2000-05-30  0:00 ` Antonio Dur�n Dom�nguez
  -- strict thread matches above, loose matches on Subject: below --
1996-09-28  0:00 Robert Dewar
1996-09-17  0:00 John Goodenough
1996-09-17  0:00 Marin David Condic, 407.796.8997, M/S 731-93
1996-09-19  0:00 ` Larry Kilgallen
1996-09-13  0:00 Marin David Condic, 407.796.8997, M/S 731-93
1996-09-15  0:00 ` Larry Kilgallen
1996-09-23  0:00 ` Robin Vowels
1996-09-12  0:00 Robbie Gates
1996-09-12  0:00 ` Bryce
1996-09-12  0:00   ` Larry Kilgallen
1996-09-13  0:00     ` Robbie Gates
1996-09-14  0:00       ` Paul A. Houle
1996-09-18  0:00         ` Rick Decker
1996-09-12  0:00 ` Patrick Doyle
1996-09-12  0:00   ` Rick Decker
1996-09-13  0:00     ` Larry Kilgallen
1996-09-13  0:00 ` Felix Kasza
1996-09-13  0:00   ` David B. Shapcott [C]
1996-09-18  0:00     ` Bart Termorshuizen
1996-09-16  0:00 ` Norman H. Cohen
1996-09-23  0:00   ` Robin Vowels
1996-09-24  0:00     ` Bob Halpern
1996-10-02  0:00       ` Fritz Schneider
1996-10-07  0:00         ` Robin Vowels
1996-10-09  0:00         ` shmuel
1996-10-09  0:00           ` Bob Halpern
1996-09-26  0:00     ` Thiago
1986-05-13 22:57 exception handling MIXSIM
replies disabled

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