[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exceptions
From: |
Norbert Nemec |
Subject: |
Re: Exceptions |
Date: |
Tue, 10 Oct 2000 09:11:31 +0200 |
User-agent: |
Mutt/1.0.1i |
On Tue, Oct 10, 2000 at 07:01:26PM +1300, Keith Hopper wrote:
> I wrote on exceptions to the news group a couple of days ago - but
> they don't appear here (yet?).
I read it already. Was very conclusive!
> In a nut-shell there are two possible uses of exceptions and exception
> handling depending on your philosophy of programming :-
>
> (1) An exception is only raised when something occurs at run-time which
> -prevents- proper termination of some method.
>
> (2) Every time that something 'unexpected' occurs use an exception.
Why be restrictive? OK, it is one way to say: exceptions are evil,
prevent to use them if possible at all. Still: I consider exceptions as
a fundamental language feature - as long as long as it is used with
care!
What is lacking in Sather is a mechanism to specify which exceptions a
method may raise. After all, that really is part of the interface. If
we had such a thing, exceptions would just become a special kind of
return value. In many cases, there are three alternatives:
(1) Force the programmer to check for the executability of a method
beforehand and throw in a pre-condition.
(2) Let the method return a special value (like "void") in case of such
an execution.
(3) Throw a well-defined exception.
In many cases those three would be interchangable. In each case, the
user of the method needs to know about it and handle the error-case in
a certain way.
I know, Keith, that this will probably again touch out main difference
in conception, but to me it is most important to always find the way
that is most comfortable for the user, and this is a thing that has to
be considered looking at examples.
Ciao,
Nobbi
--
-- ______________________________________________________
-- JESUS CHRIST IS LORD!
-- To Him, even that machine here has to obey...
--
-- _________________________________Norbert "Nobbi" Nemec
-- Hindenburgstr. 44 ... D-91054 Erlangen ... Germany
-- eMail: <address@hidden> Tel: +49-(0)-9131-204180
- Exceptions, was newbie questions, Lars Hupfeldt Nielsen, 2000/10/01
- Re: Exceptions, Norbert Nemec, 2000/10/01
- Re: Exceptions, Quinn Dunkan, 2000/10/01
- Re: Exceptions, Keith Hopper, 2000/10/10
- Re: Exceptions,
Norbert Nemec <=
- Re: Exceptions, Keith Hopper, 2000/10/10
- Re: Exceptions, Norbert Nemec, 2000/10/11
- Re: Exceptions, Keith Hopper, 2000/10/13
- Re: Exceptions, Norbert Nemec, 2000/10/16
- Re: Exceptions, Keith Hopper, 2000/10/17
- Re: Exceptions, Norbert Nemec, 2000/10/17
- Message not available
- Re: Exceptions, Norbert Nemec, 2000/10/11
- Re: Exceptions, Quinn Dunkan, 2000/10/13