comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: OT: A bit  of Sudoku
Date: Fri, 6 Jun 2014 08:47:02 -0700 (PDT)
Date: 2014-06-06T08:47:02-07:00	[thread overview]
Message-ID: <60fda787-b248-4355-a386-6463c093925f@googlegroups.com> (raw)
In-Reply-To: <1l2x0kuk3kxqx$.1owim8xhlww7x.dlg@40tude.net>

On Friday, June 6, 2014 12:51:47 AM UTC-7, Dmitry A. Kazakov wrote:

> > Otherwise, someone could look at a subprogram that is called in between,
> > and never guess that the subprogram might not complete normally (A calls
> > B, B calls C, C raises an exception that gets passed over B's head back to
> > A; a programmer trying to read B might not suspect that B may not complete
> > in a non-error situation.)  In other words, keep such usages as localized
> > as possible.
> 
> Rather, let Ada 2X formalize exception contracts and leave checking the
> contracts to the compiler.
> 
> The scenario you described is the valid and very useful use case of
> exceptions. The reason is that, likely, C and B could not handle the state
> when the exception was raised and propagated because in order to be able to
> handle it, they must be redesigned completely. They must have the
> information hidden from them for very good reason, affect program states
> possibly unrelated to them etc. I.e. it would make the design tightly
> coupled and fragile. The idea of exception is postponing handling of some
> [exceptional] states up to a context where handling were possible, e.g. in
> A. That context can be and usually is totally unknown to the designer of
> the code raising the exception.

I'm not sure we're on the same page.  What you're describing sounds more like the "normal" use case for exceptions, as I understand it (i.e. for "exceptional" conditions); but I thought the discussion was about something different, namely using exceptions as sort of a stack-unwinding "goto".  Even with an explicit contract, it still seems like using exceptions in this way, for non-exceptional situations, is going to impair readability if its use isn't kept within a small, local area of the source.  This is just my instinct, though, and I'm finding it difficult to explain why.  

                               -- Adam

  parent reply	other threads:[~2014-06-06 15:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 17:49 OT: A bit of Sudoku Mike H
2014-06-05 18:30 ` Adam Beneschan
2014-06-05 19:00   ` J-P. Rosen
2014-06-05 19:18     ` Jeffrey Carter
2014-06-05 19:43       ` J-P. Rosen
2014-06-05 20:05     ` Mike H
2014-06-05 23:12     ` Robert A Duff
2014-06-05 23:39       ` Adam Beneschan
2014-06-06  7:51         ` Dmitry A. Kazakov
2014-06-06  9:21           ` Georg Bauhaus
2014-06-06 13:38             ` Dmitry A. Kazakov
2014-06-06 15:47           ` Adam Beneschan [this message]
2014-06-06 17:09             ` Dmitry A. Kazakov
2014-06-07  6:03             ` J-P. Rosen
2014-06-06 14:13         ` Brad Moore
2014-06-13  0:21     ` Shark8
2014-06-13  6:30       ` J-P. Rosen
2014-06-13 10:10       ` Mike H
2014-06-13 12:37         ` Dmitry A. Kazakov
2014-06-13 15:47         ` Shark8
2014-06-05 20:03   ` Mike H
2014-06-05 20:40     ` Adam Beneschan
2014-06-06  9:10       ` Stefan.Lucks
2014-06-06 10:59         ` Mike H
2014-06-06 16:06         ` Adam Beneschan
replies disabled

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