comp.lang.ada
 help / color / mirror / Atom feed
From: dick_rumsfeld@yahoo.com (Dick Rumsfeld)
Subject: Getting started with Ada: Runtime exceptions?
Date: 27 Nov 2001 16:47:30 -0800
Date: 2001-11-28T00:47:30+00:00	[thread overview]
Message-ID: <3e076d85.0111271647.338f33d@posting.google.com> (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;



             reply	other threads:[~2001-11-28  0:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-28  0:47 Dick Rumsfeld [this message]
2001-11-28  1:29 ` Getting started with Ada: Runtime exceptions? Jeffrey Carter
replies disabled

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