comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Interesting effects in array renaming
Date: Tue, 24 Jun 2003 10:08:43 +0000 (UTC)
Date: 2003-06-24T10:08:43+00:00	[thread overview]
Message-ID: <slrnbfg8p9.nq.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: bd8uqg$q0jfa$2@ID-77047.news.dfncis.de

* Dmitry A. Kazakov wrote:
> It povides additional safety for the reader of a program. [Isn't a goal Ada 
> design?] It would allow to omit range checks many cases like:
> 
> procedure Sum (L : in out Vector; R : Vector) is
>    subtype Of_L is Vector (L'Range);
>    RR : Of_L renames R; -- Checked here
> begin
>    for I in L'Range loop
>       L (I) := L (I) + RR (I); -- No range check needed

Currently this is not the case:

$ cat > test.adb <<END
procedure Test is
   type Vector is array (Integer range <>) of Integer;

   procedure Sum (L : in out Vector; R : Vector) is
      subtype Of_L is Vector (L'Range);
      RR : Of_L renames R; -- Checked here
   begin
      for I in L'Range loop
	 L (I) := L (I) + RR (I); -- No range check needed
      end loop;
   end Sum;
   
   a : Vector := (4 .. 10 => 4);
   b : Vector := (1, 2, 3);
begin
   Sum(a, b);
end Test;
END
$ gnatmake test
gcc -c test.adb
gnatbind -x test.ali
gnatlink test.ali
gnatlink: warning: executable name "test" may conflict with shell command
$ ./test
raised CONSTRAINT_ERROR : test.adb:10
$ sed -n 10p test.adb
         L (I) := L (I) + RR (I); -- No range check needed
$ _



  reply	other threads:[~2003-06-24 10:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-22 14:52 Interesting effects in array renaming Dmitry A. Kazakov
2003-06-22 17:24 ` Jeffrey Carter
2003-06-23  8:12   ` Dmitry A. Kazakov
2003-06-23 10:29     ` Georg Bauhaus
2003-06-23 11:37       ` Dmitry A. Kazakov
2003-06-23 13:28         ` Georg Bauhaus
2003-06-24  7:35           ` Dmitry A. Kazakov
2003-06-24 14:38             ` Georg Bauhaus
2003-06-25 10:28               ` Dmitry A. Kazakov
2003-06-25 14:23                 ` Georg Bauhaus
2003-06-25 19:00                   ` Dmitry A. Kazakov
2003-06-24  2:35     ` Robert I. Eachus
2003-06-24  7:35       ` Dmitry A. Kazakov
2003-06-24 10:08         ` Lutz Donnerhacke [this message]
2003-06-24 11:53         ` Georg Bauhaus
2003-06-24 12:48           ` Dmitry A. Kazakov
2003-06-26  2:54             ` Randy Brukardt
2003-06-26  6:27               ` Vinzent Hoefler
2003-06-26 12:44                 ` Georg Bauhaus
2003-06-26 13:01                   ` Vinzent Hoefler
replies disabled

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