comp.lang.ada
 help / color / mirror / Atom feed
* Optional Sequence of Statements Before Exception Handlers
@ 1990-06-29 14:15 Ed Matthews
  1990-06-30 17:21 ` Richard Pattis
  0 siblings, 1 reply; 3+ messages in thread
From: Ed Matthews @ 1990-06-29 14:15 UTC (permalink / raw)


I've been thinking about the following situation recently:

  exception
    when foo_error =>
      A;
      B;
    when bar_error =>
      A;
      B;
      C;
    when others =>
      A;
      B;
      D;
  end;

and wondering if allowing the following would be a "good thing:"

  exception
    A;
    B;  -- these two statements comprise the optional sequence before handlers
    when foo_error =>
      null;
    when bar_error =>
      C;
    when others =>
      D;
  end;

This obviously poses some awkward spots -- like the null; statement with
non-null semantics and if an exception occurs in the optional sequence
of statement, where/how/in which scope it can be handled.  

Of course, we can always write a procedure encapsulating A; B; and call it
from each of the handlers.  Then we get into the wouldn't it be nice if
we could pass parameters to handlers and access the name of the exception
(or an enumeration literal representing the exception) in a standard manner.

Anybody know what the current thinking about exception handling is with
respect to 9X?
-- 

Ed Matthews                                                edm@verdix.com
Verdix Corporation Headquarters                            (703) 378-7600
Chantilly, Virginia

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Optional Sequence of Statements Before Exception Handlers
  1990-06-29 14:15 Optional Sequence of Statements Before Exception Handlers Ed Matthews
@ 1990-06-30 17:21 ` Richard Pattis
  1990-07-03  9:51   ` Daniel Wengelin
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Pattis @ 1990-06-30 17:21 UTC (permalink / raw)


In article <34741@vrdxhq.verdix.com>, edm@vrdxhq.verdix.com (Ed Matthews) writes:
> I've been thinking about the following situation recently:
> 
>   exception
>     when foo_error =>
>       A;
>       B;
>     when bar_error =>
>       A;
>       B;
>       C;
>     when others =>
>       A;
>       B;
>       D;
>   end;
> 
> and wondering if allowing the following would be a "good thing:"
> 
>   exception
>     A;
>     B;  -- these two statements comprise the optional sequence before handlers
>     when foo_error =>
>       null;
>     when bar_error =>
>       C;
>     when others =>
>       D;
>   end;
> 

How about:


EXCEPTION
  WHEN OTHERS =>
      A;
      B;
      BEGIN
        RAISE;
      EXCEPTION
         WHEN foo_error => NULL;
         WHEN bar_error => C;
         WHEN others    => D;
      END;
      -- Can put post statements here (done for all exceptions)
END;

Rich Pattis

PS: Actually, I've never programmed this, but I have thought about it; if it
won't work, I'm sure some kind soul will tell me so, loudly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Optional Sequence of Statements Before Exception Handlers
  1990-06-30 17:21 ` Richard Pattis
@ 1990-07-03  9:51   ` Daniel Wengelin
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Wengelin @ 1990-07-03  9:51 UTC (permalink / raw)


In article <12427@june.cs.washington.edu>, pattis@cs.washington.edu
(Richard Pattis) writes:
 EXCEPTION
   WHEN OTHERS =>
       A;
       B;
       BEGIN
         RAISE;
       EXCEPTION
          WHEN foo_error => NULL;
          WHEN bar_error => C;
          WHEN others    => D;
       END;
       -- Can put post statements here (done for all exceptions)
 END;
 PS: Actually, I've never programmed this, but I have thought about it; if it
 won't work, I'm sure some kind soul will tell me so, loudly.

The code above was tested on a Sun3/60 using Telesofts TELEGEN2 SunAda 1.4.
It works just fine !

Daniel Wengelin.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1990-07-03  9:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-06-29 14:15 Optional Sequence of Statements Before Exception Handlers Ed Matthews
1990-06-30 17:21 ` Richard Pattis
1990-07-03  9:51   ` Daniel Wengelin

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