comp.lang.ada
 help / color / mirror / Atom feed
* Semantics Question
@ 1993-01-06  1:23 munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fraser
  0 siblings, 0 replies; 2+ messages in thread
From: munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fraser @ 1993-01-06  1:23 UTC (permalink / raw)


Hi.  I have a small question regarding exceptions, the answer to which
I couldn't find in the ARM.  Basically, what happens if you raise a
local exception, but don't handle it before the end of the block in which
it is declared.  Like this:

procedure p is

  procedure q is
    e : exception;
  begin
    raise e;
  end q;

begin
  q;
end p;


Is the result defined somewhere, or not?  If there are handlers in
subprograms that call p, and they handle any exception (ie, with an
others clause), will they catch e?  Should the program abort as soon
as it leaves e's scope?

Thanks in advance,
Fraser.
======================================================================== \._,
Can death be sleep, when life is but a dream  | Fraser Wilson,           < /
And scenes of bliss pass as a phantom by?     | Melbourne University     _'
The transient pleasures as a vision seem      | fraser@cs.mu.OZ.AU      //
And yet we think the greatest pain's to die.  | Phone - +61 3 344 7877 // NZ!
============================meat is murder===================================

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

* Re: Semantics Question
@ 1993-01-06 18:10 Mark A Biggar
  0 siblings, 0 replies; 2+ messages in thread
From: Mark A Biggar @ 1993-01-06 18:10 UTC (permalink / raw)


In article <9300612.21535@mulga.cs.mu.OZ.AU> fraser@munta.cs.mu.OZ.AU (Fraser W
ilson) writes:
>Hi.  I have a small question regarding exceptions, the answer to which
>I couldn't find in the ARM.  Basically, what happens if you raise a
>local exception, but don't handle it before the end of the block in which
>it is declared.  Like this:
>procedure p is
>  procedure q is
>    e : exception;
>  begin
>    raise e;
>  end q;
>begin
>  q;
>end p;
>Is the result defined somewhere, or not?  If there are handlers in
>subprograms that call p, and they handle any exception (ie, with an
>others clause), will they catch e?  Should the program abort as soon
>as it leaves e's scope?

This is well defined. See LRM 11.2.5.  Exceptions whose names are not visible
in the curent scope (this includes excetptions propagated out of scope) can be
handled using a "when others =>" exception handler.  Ada9x does the same thing
but also provides a method of getting a name string for the exception so that 
at least you can output a reasonable report before dying.

--
Mark Biggar
mab@wdl1.wdl.loral.com

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

end of thread, other threads:[~1993-01-06 18:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-01-06 18:10 Semantics Question Mark A Biggar
  -- strict thread matches above, loose matches on Subject: below --
1993-01-06  1:23 munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fraser

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