comp.lang.ada
 help / color / mirror / Atom feed
* Getting started with Ada: Runtime exceptions?
@ 2001-11-28  0:47 Dick Rumsfeld
  2001-11-28  1:29 ` Jeffrey Carter
  0 siblings, 1 reply; 2+ messages in thread
From: Dick Rumsfeld @ 2001-11-28  0:47 UTC (permalink / raw)


Hello all,
I've just today started to learn Ada. In Section 1.4 of the online
tutorial I am learning from,
http://www.adahome.com/Tutorials/Lovelace/s1sf.htm
it is stated that the below program, when run, will print 2^n for each
n starting with n=0, until an overflow occurs, at which time the
program will automatically halt with a message stating an exception
occured. Well, when I compiled and ran the below program using
"gnatmake" (which I've just downloaded for my Linux distribution), it
gives the following output:

          1
          2
          4
          8
       [...output elided...]
  536870912
 1073741824
-2147483648
          0
          0
          0
         ...

This looks more like the behavior I would expect from C. So then, what
do I need to do to get what I presume from the tutorial to be the
proper exception generating behavior?

Here is the program:

-- Demonstrate a trivial procedure, with another nested inside.
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
 
procedure Compute is

 procedure Double(Item : in out Integer) is
 begin -- procedure Double.
   Item := Item * 2;
 end Double;

 X : Integer := 1;   -- Local variable X of type Integer.

begin -- procedure Compute
 loop
  Put(X);
  New_Line;
  Double(X);
 end loop;
end Compute;



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

end of thread, other threads:[~2001-11-28  1:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-28  0:47 Getting started with Ada: Runtime exceptions? Dick Rumsfeld
2001-11-28  1:29 ` Jeffrey Carter

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