comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Exceptions
Date: Mon, 10 Dec 2007 11:56:19 +0100
Date: 2007-12-10T11:48:36+01:00	[thread overview]
Message-ID: <194zh0rz03487$.6vxhavjdbpdr.dlg@40tude.net> (raw)
In-Reply-To: 475d04ea$0$13113$9b4e6d93@newsspool2.arcor-online.net

On Mon, 10 Dec 2007 10:20:38 +0100, Georg Bauhaus wrote:

> Do programmers put a block around every procedure call so
> that the proper occurence of Constraint_Error is handled?

Yes if Constraint_Error shall not propagate further. What is the
alternative BTW? To say that it does not propagate, but let it do?

Note that to argue against exception contracts on the basis that handling
exceptions is difficult is a fallacy. It is like to argue that
floating-point type is bad because calculating sine is difficult.

> And will this likelyhood increase once subp declarations
> announce foreseeable exceptions?
> 
>> 2. How often does a caller "eat" an exception of the callee instead of
>> propagating it further? My guess is 1 / 10.
> 
> Are you assuming current rules for guessing 10% exception handling,
> i.e., no exceptions are announced by the subprogram declaration?

I meant that an exception is typically propagated out of 10 scopes before
it gets handled.

>> There is not that many handlers in a good designed code.
> 
> Hear, hear. [Q] Why do we need more exception announcements, then?

Because of the damage an unhandled exception does. The goal of software
design is to minimize the damage caused by program execution (the best way
is not to write any programs at all (:-)).

Lesser likelihood of exception propagation is compensated by the damage
inflicted by.

> Will design improve because of subp with exception announcements?

This is a different question. Clearly any language change has certain
effect on the programming practices and average design. I cannot foresee
how contracts would influence us, programmers. I can only say that
contracted exceptions are well in Ada spirit.

>> This is probably
>> the reason why people forget to handle exceptions properly. They are not
>> that visible.
> 
> If programmers do not handle exceptions properly when they
> do not see them in source, will forcing them to handle exceptions
> make them handle exceptions _properly_?

Exactly so. They still will have an option to keep on ignoring exceptions.
Only if they will announce the program as exception E free, only then, they
will be forced to take care of E. Looks reasonable to me.

> I have seen a number of null handlers...
> 
> My guess is that missing else branches or undocumented null "others"
> in case distinctions are a related issue. The issue really is
> handling cases, not announcing them. Every if implies the possibility
> of an else. Still we can have null else branches (or "others" choises).

No, only in absence of a contract. Consider:

function Foo return ... is
begin
   if ... then
      return ...;
   end if;
end Foo;

This is illegal because of the contract to return a value. I hope you do
not propose to make Foo legal because required "else" would spoil so nicely
formatted code? (:-))

Exception non-propagation contracts fall under this category.

> If only the Algol symbol "comment" had been given more emphasis
> in successor languages. A friendly tell-us-what-you-think!
> mechanism is better IMHO than a combination of force together with a
> force absorbing mechanism! (Exception "contracts" together with
> null handlers and the like.)
> 
>    case Traffic_Light is
>       when Red => ... ;
>       when Green => .... ;
>       when others =>
>          comment No comment;
>          null;  -- forces the comment.
>          -- Hypothesis: the comment "No comment" will not
>          -- pass quality control
>    end case;
> 
> Remove "others" from the languge? :-)

The problem here is not others. The problem is the power of a language
construct. Others is harmless if it includes only Blue. It can be damaging
if it does "all other Integers." Ideally the constructs should be as weak
as possible to be able to accomplish the goal. Goto or template solve the
problem but they call the devil who won't go back. So "others" does when it
refers to a set of big cardinality then covered by null-action.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2007-12-10 10:56 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-06 15:00 Exceptions shaunpatterson
2007-12-06 21:24 ` Exceptions tmoran
2007-12-07  8:54   ` Exceptions Dmitry A. Kazakov
2007-12-07 10:21     ` Exceptions Georg Bauhaus
2007-12-07 15:11       ` Exceptions shaunpatterson
2007-12-07 16:08         ` Exceptions Gautier
2007-12-07 18:56         ` Exceptions Simon Wright
2007-12-08 10:04         ` Exceptions Stephen Leake
2007-12-08  3:30     ` Exceptions Randy Brukardt
2007-12-08 10:09       ` Contracted exceptions for Ada (was: Exceptions) Dmitry A. Kazakov
2007-12-09 10:22         ` Contracted exceptions for Ada Stephen Leake
2007-12-09 11:02           ` Dmitry A. Kazakov
2007-12-11  8:10             ` Stephen Leake
2007-12-11 10:36               ` Dmitry A. Kazakov
2007-12-09 15:11         ` Contracted exceptions for Ada (was: Exceptions) Martin Krischik
2007-12-09 17:36           ` Contracted exceptions for Ada Dmitry A. Kazakov
2007-12-09 18:39             ` Simon Wright
2007-12-10  8:19               ` Dmitry A. Kazakov
2007-12-10 20:25                 ` Simon Wright
2007-12-11  8:50                   ` Dmitry A. Kazakov
2007-12-11 20:50                     ` Simon Wright
2007-12-12 10:20                       ` Dmitry A. Kazakov
2007-12-09 19:04             ` Martin Krischik
2007-12-10  8:20               ` Dmitry A. Kazakov
2007-12-09 22:09         ` Robert A Duff
2007-12-10  7:09           ` Stefan Lucks
2007-12-10 16:57             ` Robert A Duff
2007-12-11  1:53         ` Contracted exceptions for Ada (was: Exceptions) Randy Brukardt
2007-12-11  9:16           ` Contracted exceptions for Ada Dmitry A. Kazakov
2007-12-12  0:26             ` Randy Brukardt
2007-12-08 12:26       ` Exceptions Peter C. Chapin
2007-12-08 14:01         ` Exceptions Dmitry A. Kazakov
2007-12-08 18:01           ` Exceptions Peter C. Chapin
2007-12-09 10:06             ` Exceptions Dmitry A. Kazakov
2007-12-09 12:40               ` Exceptions Peter C. Chapin
2007-12-09 14:31                 ` Exceptions Dmitry A. Kazakov
2007-12-09 16:38                   ` Exceptions Peter C. Chapin
2007-12-10  8:31                     ` Exceptions Dmitry A. Kazakov
2007-12-09 21:56                 ` Exceptions Robert A Duff
2007-12-09 10:24             ` Exceptions Stephen Leake
2007-12-09 12:46               ` Exceptions Peter C. Chapin
2007-12-09 21:39   ` Exceptions Robert A Duff
2007-12-09 22:13     ` Exceptions Georg Bauhaus
2007-12-11  8:07       ` Exceptions Stephen Leake
2007-12-11 20:28         ` Exceptions Simon Wright
2007-12-12 22:10         ` Exceptions Maciej Sobczak
2007-12-13 13:40           ` Exceptions Robert A Duff
2007-12-13 14:00             ` Exceptions Maciej Sobczak
2007-12-13 14:44               ` Exceptions Robert A Duff
2007-12-14  0:46                 ` Exceptions Ray Blaak
2007-12-14  2:36                   ` Exceptions Randy Brukardt
2007-12-14  6:21                     ` Exceptions Ray Blaak
2007-12-14 12:40                       ` Exceptions Georg Bauhaus
2007-12-14 17:29                   ` Exceptions Robert A Duff
2007-12-14 19:32                     ` Exceptions Dmitry A. Kazakov
2007-12-15  5:29                     ` Exceptions Ray Blaak
2007-12-13 19:29               ` Exceptions Randy Brukardt
2007-12-12 19:18     ` Exceptions Martin Krischik
2007-12-13 13:27       ` Exceptions Robert A Duff
2007-12-13 23:25       ` Exceptions Ray Blaak
2007-12-06 21:25 ` Exceptions Gautier
2007-12-07  4:29 ` Exceptions anon
2007-12-07  4:43 ` Exceptions, part 2 anon
2007-12-07 16:55 ` Exceptions Adam Beneschan
2007-12-07 18:59   ` Exceptions Simon Wright
2007-12-08  0:38     ` Exceptions Adam Beneschan
2007-12-09 21:45     ` Exceptions Robert A Duff
2007-12-09 22:40       ` Exceptions Georg Bauhaus
2007-12-10  8:22         ` Exceptions Dmitry A. Kazakov
2007-12-10  9:20           ` Exceptions Georg Bauhaus
2007-12-10  9:30             ` Exceptions Georg Bauhaus
2007-12-10 10:56             ` Dmitry A. Kazakov [this message]
2007-12-11  2:18               ` Exceptions Randy Brukardt
2007-12-11  8:19               ` Exceptions Georg Bauhaus
2007-12-11 11:55                 ` Exceptions Dmitry A. Kazakov
2007-12-11 16:13                   ` Exceptions Georg Bauhaus
2007-12-12 11:18                     ` Exceptions Dmitry A. Kazakov
2007-12-10 12:09           ` Exceptions Niklas Holsti
2007-12-10 13:08             ` Exceptions Dmitry A. Kazakov
2007-12-10 20:02               ` Exceptions Niklas Holsti
2007-12-11 12:31                 ` Exceptions Dmitry A. Kazakov
2007-12-11 13:21                   ` Exceptions Niklas Holsti
2007-12-12  0:01                     ` Exceptions Randy Brukardt
2007-12-12 11:37                       ` Exceptions Niklas Holsti
2007-12-12 13:14                         ` Exceptions Dmitry A. Kazakov
2007-12-12 14:37                       ` Exceptions Robert A Duff
2007-12-13 19:20                         ` Exceptions Randy Brukardt
2007-12-13 20:15                           ` Exceptions Robert A Duff
2007-12-12 11:00                     ` Exceptions Dmitry A. Kazakov
2007-12-11  2:12           ` Exceptions Randy Brukardt
2007-12-11 15:17             ` Exceptions Robert A Duff
2007-12-12  0:10               ` Exceptions Randy Brukardt
2007-12-13 19:58                 ` Exceptions Robert A Duff
2007-12-14  0:53                 ` Exceptions Ray Blaak
2007-12-14  2:48                   ` Exceptions Randy Brukardt
2007-12-14  6:33                     ` Exceptions Ray Blaak
2007-12-08 10:03 ` Exceptions Stephen Leake
  -- strict thread matches above, loose matches on Subject: below --
1991-03-06 17:24 Exceptions David Erickson
1991-03-06 21:21 ` Exceptions Jerry Callen
1989-06-23 21:57 Exceptions howell
replies disabled

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