comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: Structured exception information
Date: Sat, 20 Jan 2007 10:33:40 -0500
Date: 2007-01-20T10:33:40-05:00	[thread overview]
Message-ID: <uac0dyap7.fsf@stephe-leake.org> (raw)
In-Reply-To: eoqhhm$fjp$1@cernne03.cern.ch

Maciej Sobczak <no.spam@no.spam.com> writes:

> Again - going down this route, what's wrong with having only strings
> in the language? Tcl is a powerful language that is quite successful
> with only strings.

That's absurd.

I said "Strings are the correct type for presenting information to the
user".

My full system uses strings for that purpose. It uses many other
types for other purposes; quaternions for orientation, unbounded
arrays for dynamic lists, binary trees for sorted symbol tables, hash
tables for fast lookup of symobls, a class hierarchy with abstract
operations for models, records with bit-level representation clauses
for hardware registers. Etc. 

>> You have not said _why_ you need to dismantle this information in the
>> handler. What, _exactly_, will the handler do with the separate bits?
>
> Looking up the localized error message in the dictionary based on the
> *type-safe* error code that it got from the exception object,
> probably?

Why would it do that? The original problem was "present this
information to the user".

Again, I'm asking for a _detailed_, _real_ example!

> I expect *type-safe* error code which I can look up in the dictionary.

Well, ok, that's a fairly clear requirement. And yes, Ada exceptions
cannot include a type-safe error code.

But I don't understand _why_ you want to do that in the exception
handler. Why didn't the callee look up the error code, and put the
string in the exception message?

What will the exception handler do with the result of the lookup?

> I'm looking forward to see a convincing solution for error code and
> the dictionary.

You have not defined "dictionary" here. If I assume it just contains
strings, and the handler will simply output that string to
Standard_Error, then having the callee do the lookup is a perfectly
reasonable solution.

>>>> As a general matter of user-interface design, I would find that
>>>> annoying. As a user of a system, the only thing I want from an error
>>>> message is either "how do I fix this myself" or "how do I report this
>>>> to the maintenance team".
>>> That is a reasonable approach and will work fine most of the time,
>> When will it not work? I have never encountered such a case.
>
> It will not work in those cases where the handler might attempt to
> "fix things" and retry the operation that failed instaed of displaying
> the "sorry" message.
> Consider for example a compuational algorithm that failed to allocate
> some memory that was needed for computations. Exception 
> is raised and goes up to the handler that as a first attempt tries
> to flush some in-memory caches or other transient buffers and
> restarts the computation with the hope that it can now succeed with
> more memory available in the system. There is no need to display
> anything to the user and string format has no use here. Even for
> this simple case I can imagine that the code in question can include
> in the exception object the size of the allocation that failed, so
> that the handler can make more optimal decisions as to what should
> be flushed. In such a case, I'd expect the size information to
> retain the type safety that should be there from the very beginning.

Ok, that's a concrete example. Thank you.

>> If you look into the details of "structured exception handling" in
>> other languages and implementations, they have bugs, and fundamental
>> flaws in design.
>
> Ada does not have this, because it *might* be difficult for
> implementers? 

Not "might be difficult", but "is impossible to get truly right in
_all_ cases required by the language". Hmm. "impossible" may be too
strong. "we know of no way to do it" is probably closer. As Randy has
been saying, now that the rest of Ada has evolved, it may be that we
now _could_ find a way to have structured exceptions in the next
version of Ada.



> Is it better if programmers find it more difficult to write final
> programs instead?

Yes! 

Let's be clear. Here are the choices:

1) Define structured exceptions in Ada. We _know_ that _all_ compilers
will not meet the standard in some way, and each in different ways.

2) Define only strings for exceptions. Let the programmers use other
methods to solve particular problems.


In case 1), I will never be able to rely on the exception information,
so I will only use strings anyway.

>> That is why Ada did not go that way. Ada is _much_
>> more careful about getting the core design right
>
> It failed in this aspect.

Well, you are interpreting "right" to mean "has everything I want"; I
meant "is internally consistent, has no unexpected behaviors, has a
reasonable implementation approach".

>> allowing fully
>> robust and safe implementations of _all_ features
>
> Is there anything in Java or C++ or Python or whatever exception
> handling that makes it fundamentally impossible to implement correctly?

Yes, which is why none of those implementations fully meets the
standard, and each implementation differs from the others, sometimes
in subtle ways.

>> especially in
>> multi-tasking and multi-processing environments.
>
> Why should I care about multi-tasking and multi-processing
> environments when writing single-tasking programs? 

Well, that is a reasonable point. Ada made the choice to make
multi-tasking work right, as part of the language. So you may want to
choose another language, if this particular choice make Ada unsuitable
for you. 

> Should I be constrained in my work just because some feature might
> be difficult to implement elsewhere? I'd say no, but just in case I
> propose an easy solution for everybody: just forbid structured
> exceptions in multitasking and distributed environments and allow
> them where they will naturally work. BTW - somehow Java exceptions
> work fine 

By "fine" do you mean "i've never had a problem with them" or do you
mean "everyone who has studied these issues in depth agrees that the
Java implementation will _never_ have a problem"?

Those are two very different statements. I prefer a language that uses
the second approach.

The Java class libraries have lots of deprecated procedures, that
"worked fine" when they were first released, but had problems of one
sort or another when people tried to use them in unanticipated but
clearly reasonable ways. Ada tries very hard to avoid that sort of
thing, especially in the core language.

>> So if you find yourself fighting Ada to do something, you need to step
>> back and think more carefully about _why_ you are doing it that way.
>> Ada is telling you it is inherently unsafe.
>
> Sorry, I don't buy this. I stepped back, thought more carefully and I
> haven't seen any solution for looking up error code in a dictionary or
> for transmitting size information so that the handler can make optimal
> decisions before retrying memory-expensive computations.

In Ada, you need to pass back an error code of some type, or the size,
not use an exception. That is a valid solution. Using exceptions for
this is inherently unsafe.

-- 
-- Stephe



  reply	other threads:[~2007-01-20 15:33 UTC|newest]

Thread overview: 181+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-15 13:44 Structured exception information Maciej Sobczak
2007-01-15 17:17 ` claude.simon
2007-01-16  9:04   ` Maciej Sobczak
2007-01-16 22:39     ` Randy Brukardt
2007-01-15 17:28 ` Robert A Duff
2007-01-15 18:29   ` Georg Bauhaus
2007-01-15 19:44     ` Dmitry A. Kazakov
2007-01-15 20:06       ` Georg Bauhaus
2007-01-15 21:56         ` Randy Brukardt
2007-01-15 22:32           ` Robert A Duff
2007-01-16 18:36             ` Ray Blaak
2007-01-16 19:18               ` C# versus Ada (was: Structured exception information) Georg Bauhaus
2007-01-16 23:29                 ` C# versus Ada Markus E Leypold
2007-01-18 10:22                   ` Dmitry A. Kazakov
2007-01-17 18:14                 ` C# versus Ada (was: Structured exception information) Ray Blaak
2007-01-16 23:27               ` Structured exception information Markus E Leypold
2007-01-17  7:28               ` Martin Krischik
2007-01-16 22:36             ` Randy Brukardt
2007-01-17 16:12               ` Bob Spooner
2007-01-17 23:42                 ` Randy Brukardt
2007-01-16  9:11           ` Dmitry A. Kazakov
2007-01-16 10:45             ` Maciej Sobczak
2007-01-16 13:26               ` Dmitry A. Kazakov
2007-01-16 14:44                 ` Maciej Sobczak
2007-01-16 15:15                   ` Dmitry A. Kazakov
2007-01-16 17:50             ` Jeffrey Carter
2007-01-16 18:31               ` Dmitry A. Kazakov
2007-01-16 22:52                 ` Randy Brukardt
2007-01-17  8:58                   ` Dmitry A. Kazakov
2007-01-17 18:38                     ` Jeffrey Carter
2007-01-17 23:18                       ` Randy Brukardt
2007-01-17 23:46                         ` Robert A Duff
2007-01-18  6:34                         ` Jeffrey Carter
2007-01-19  7:34                           ` Randy Brukardt
2007-01-19 13:52                             ` Dmitry A. Kazakov
2007-01-19 18:57                               ` Jeffrey Carter
2007-01-19 19:57                                 ` Robert A Duff
2007-01-20 20:59                                   ` Jeffrey Carter
2007-01-18  9:55                       ` Dmitry A. Kazakov
2007-01-18 18:28                         ` Jeffrey Carter
2007-01-17 23:36                     ` Randy Brukardt
2007-01-18 10:16                       ` Dmitry A. Kazakov
2007-01-15 22:19     ` Robert A Duff
2007-01-16 13:12       ` Georg Bauhaus
2007-01-15 22:42 ` Adam Beneschan
2007-01-15 23:22   ` Robert A Duff
2007-01-16  6:03     ` tmoran
2007-01-16 13:30 ` Stephen Leake
2007-01-16 14:33   ` Maciej Sobczak
2007-01-16 14:45     ` Georg Bauhaus
2007-01-16 17:54     ` Jeffrey Carter
2007-01-16 22:55       ` Randy Brukardt
2007-01-17 12:10     ` Stephen Leake
2007-01-17 14:05       ` Maciej Sobczak
2007-01-19  9:47         ` Stephen Leake
2007-01-19 11:03           ` Dmitry A. Kazakov
2007-01-20 15:04             ` Stephen Leake
2007-01-21 10:40               ` Dmitry A. Kazakov
2007-01-23  7:28                 ` Stephen Leake
2007-01-23 14:21                   ` Dmitry A. Kazakov
2007-01-25  2:39                     ` Stephen Leake
2007-01-19 13:36           ` Maciej Sobczak
2007-01-20 15:33             ` Stephen Leake [this message]
2007-01-20 16:33               ` Robert A Duff
2007-01-21 22:42                 ` Stephen Leake
2007-01-21 23:45                   ` Robert A Duff
2007-01-22  9:14                     ` Maciej Sobczak
2007-01-23  7:33                     ` Stephen Leake
2007-01-23 15:07                       ` Robert A Duff
2007-01-23 15:54                         ` Maciej Sobczak
2007-01-23 17:10                           ` Robert A Duff
2007-01-23 23:59                       ` Randy Brukardt
2007-01-22  9:28               ` Maciej Sobczak
2007-01-23  9:46                 ` Stephen Leake
2007-01-23 14:18                   ` Maciej Sobczak
2007-01-25  2:32                     ` Stephen Leake
2007-01-25  8:53                       ` Maciej Sobczak
2007-01-26  9:35                         ` Stephen Leake
2007-01-26 11:16                           ` Markus E Leypold
2007-01-26 13:46                           ` Georg Bauhaus
2007-01-27 18:17                             ` Stephen Leake
2007-01-28 12:38                               ` Simon Wright
2007-01-28 12:39                               ` Simon Wright
2007-01-28 13:18                               ` Stephen Leake
2007-01-28 15:44                                 ` Georg Bauhaus
2007-01-28 21:48                                 ` Ray Blaak
2007-01-28 18:50                               ` Georg Bauhaus
2007-01-30  2:15                                 ` Stephen Leake
2007-01-31 18:58                                   ` Georg Bauhaus
2007-02-01 12:20                                     ` Stephen Leake
2007-02-01 14:17                                       ` Georg Bauhaus
2007-01-25 21:52                       ` Randy Brukardt
2007-01-24  0:10                   ` Randy Brukardt
2007-01-24 14:17                     ` Wasteful internationalization (Was: Structured exception information) Alex R. Mosteo
2007-01-24 14:49                       ` Dmitry A. Kazakov
2007-01-24 23:48                         ` Wasteful internationalization Björn Persson
2007-01-25  9:45                           ` Markus E Leypold
2007-01-24 21:03                       ` Wasteful internationalization (Was: Structured exception information) Randy Brukardt
2007-01-25 11:17                         ` Alex R. Mosteo
2007-01-25 21:37                           ` Wasteful internationalization Björn Persson
2007-01-25 21:57                           ` Wasteful internationalization (Was: Structured exception information) Randy Brukardt
2007-01-26  9:13                             ` Dmitry A. Kazakov
2007-01-26 12:12                               ` Georg Bauhaus
2007-01-27  4:09                               ` Randy Brukardt
2007-01-27 17:15                             ` Wasteful internationalization Stephen Leake
2007-01-27 20:44                               ` Markus E Leypold
2007-01-28  0:09                                 ` Björn Persson
2007-01-28  1:08                                   ` Björn Persson
2007-01-28 15:21                                     ` Markus E Leypold
2007-01-29  1:23                                       ` Larry Kilgallen
2007-01-29 19:02                                         ` Björn Persson
2007-01-29 20:19                                           ` Larry Kilgallen
2007-02-01  6:23                                             ` Simon Wright
2007-02-03  0:48                                             ` Björn Persson
2007-02-03  1:04                                               ` Adam Beneschan
2007-02-03 11:52                                                 ` Larry Kilgallen
2007-02-03  2:36                                               ` Markus E Leypold
2007-02-03  2:37                                                 ` Markus E Leypold
2007-02-03 19:59                                                 ` Björn Persson
2007-02-03 20:16                                                   ` Markus E Leypold
2007-02-05 19:26                                                     ` Björn Persson
2007-02-04  4:51                                                   ` Alexander E. Kopilovich
2007-02-05 19:27                                                     ` Björn Persson
2007-02-06  1:32                                                   ` Randy Brukardt
2007-02-06  1:54                                                     ` Markus E Leypold
2007-02-07  1:55                                                       ` Björn Persson
2007-02-07  2:20                                                         ` Markus E Leypold
2007-02-12  1:33                                                           ` Björn Persson
2007-02-12  8:16                                                             ` Franz Kruse
2007-02-12  9:20                                                             ` Not at all wasteful internationalization Martin Krischik
2007-02-12 11:08                                                               ` Georg Bauhaus
2007-02-12 13:02                                                                 ` Martin Krischik
2007-02-07 20:39                                                         ` Wasteful internationalization Randy Brukardt
2007-02-08 13:33                                                           ` Stephen Leake
2007-02-12  2:42                                                           ` Björn Persson
2007-02-06 11:01                                                     ` Peter Hermann
2007-02-06 19:02                                                     ` OT: Flash (was: Re: Wasteful internationalization) Jeffrey R. Carter
2007-02-06 19:40                                                       ` OT: Flash Markus E Leypold
2007-02-03 11:51                                               ` Wasteful internationalization Larry Kilgallen
2007-01-29 18:54                                       ` Björn Persson
2007-01-29 19:03                                         ` Markus E Leypold
2007-01-30 17:46                                           ` Georg Bauhaus
2007-01-30 19:37                                             ` Markus E Leypold
2007-01-30 20:43                                               ` Georg Bauhaus
2007-01-30 20:50                                                 ` Georg Bauhaus
2007-01-30 21:54                                                 ` Markus E Leypold
2007-01-31 11:26                                               ` Alex R. Mosteo
2007-01-31 15:17                                                 ` Markus E Leypold
2007-02-03  0:49                                                 ` Björn Persson
2007-02-03 16:05                                                   ` Alex R. Mosteo
2007-02-03  0:48                                               ` Björn Persson
2007-02-01 12:08                                             ` Stephen Leake
2007-02-03  0:49                                               ` Björn Persson
2007-02-03  9:46                                                 ` Dmitry A. Kazakov
2007-02-03 18:48                                                 ` Stephen Leake
2007-02-03 20:27                                                   ` Björn Persson
2007-01-30  2:20                                       ` Stephen Leake
2007-01-30 10:01                         ` Wasteful internationalization (Was: Structured exception information) Harald Korneliussen
2007-01-19 15:45           ` Structured exception information Robert A Duff
2007-01-20 16:08             ` Stephen Leake
2007-01-20 21:59               ` Robert A Duff
2007-01-19 18:14           ` Ray Blaak
2007-01-19 20:07           ` Robert A Duff
2007-01-20 16:16             ` Stephen Leake
2007-01-20 21:20               ` Ray Blaak
2007-01-21 22:34                 ` Stephen Leake
2007-01-20 22:07               ` Robert A Duff
2007-01-21 10:45                 ` Dmitry A. Kazakov
2007-01-21 23:51                   ` Robert A Duff
2007-01-22 14:39                     ` Dmitry A. Kazakov
2007-01-22 19:02                       ` Robert A Duff
2007-01-23 14:23                         ` Dmitry A. Kazakov
2007-01-29  1:30   ` Brian May
2007-01-16 13:30 ` Structured exception information (task, ANEX E) Martin Krischik
2007-01-16 23:07   ` Randy Brukardt
2007-01-19 16:01   ` Robert A Duff
2007-01-22  7:17     ` Martin Krischik
2007-01-22 19:40       ` Robert A Duff
2007-01-16 15:48 ` Structured exception information Alex R. Mosteo
2007-01-16 18:07   ` Jeffrey Carter
2007-01-17  6:38     ` Duncan Sands
replies disabled

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