comp.lang.ada
 help / color / mirror / Atom feed
* Updating IN OUT's after exceptions
@ 1991-04-30  9:18 Stuart M. Weinstein
  1991-05-01 22:56 ` stt
  0 siblings, 1 reply; 4+ messages in thread
From: Stuart M. Weinstein @ 1991-04-30  9:18 UTC (permalink / raw)


In the enclosed program, I raise an exception inside a subroutine after
making an assignment to an IN OUT parameter.  In the first case, the
parameter is a scalar, in the second it is not.  Everything else is the
same, except the resulting behavior.  Is this permitted by the LRM?
I know that compilers can pass non-scalar parameters by copy-in/copy-out
or reference, but should that effect exception handling?  Is Ada/9x
addressing this?

Thanks.

Stuart.  (weinstei@kong.gsfc.nasa.gov)

\f
with text_io;
procedure t1 is

  type intarr is array(1..50) of integer;
  zero : integer;
  a    : integer;
  arr  : intarr;

  procedure sub1(x : in out integer) is
    y : integer := 1;
  begin
    x := x + 10;
    y := y / zero; -- raise exception
  end sub1;

  procedure sub2(x : in out intarr; i : in integer) is
    y : integer := 1;
  begin
    x(i) := x(i) + 10;
    y    := y / zero; -- raise exception
  end sub2;

begin

  zero := 0;
  a := 5;
  text_io.put_line("Before sub1: A = " & integer'image(a));
  begin sub1(a); exception when others => null; end;
  text_io.put_line("After  sub1: A = " & integer'image(a));

  arr(12) := 5;
  text_io.put_line("Before sub1: ARR(12) = " & integer'image(arr(12)));
  begin sub2(arr,12); exception when others => null; end;
  text_io.put_line("After  sub1: ARR(12) = " & integer'image(arr(12)));

end;

Output from DEC Ada 2.2:

Before sub1: A =  5
After  sub1: A =  5
Before sub1: ARR(12) =  5
After  sub1: ARR(12) =  15

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

end of thread, other threads:[~1991-05-03 12:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-04-30  9:18 Updating IN OUT's after exceptions Stuart M. Weinstein
1991-05-01 22:56 ` stt
1991-05-02 17:10   ` Doug Smith
1991-05-03 12:51   ` Bill Lee

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