comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Array Help?
Date: Wed, 29 Feb 2012 21:07:45 +0100
Date: 2012-02-29T21:07:45+01:00	[thread overview]
Message-ID: <t79ae6hdlfwv.1m8cryc7jgl32.dlg@40tude.net> (raw)
In-Reply-To: wcclinl7b1x.fsf@shell01.TheWorld.com

On Wed, 29 Feb 2012 13:24:10 -0500, Robert A Duff wrote:

> Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
> 
>> Doesn't that preclude slices that don't start at 'First?
> 
> Yes.

Too bad, yet another source of silly exceptions.

>> Supposing your declarations, can you call
>>
>> procedure Foo (Param : in out Integer_Array);
>>
>> like this:
>>
>> declare
>>    A : Integer_Array (1 .. 10) := (others => 0);
>> begin
>>    Foo (A (3 .. 8));
>> end;
>>
>> ?
> 
> That will raise C_E.  IMHO, that's a language design flaw -- inside
> Foo, Param'First ought to be 1.

Nope. Consider index of an enumeration type.

> The fact that Foo can see that
> it came from a slice is a leak of abstraction.

There is no leak, but a misuse of a cardinal index as if it were ordinal
number. This is typical for broken languages like C, but Ada was always
better.

What you want is something like:

   A (Index_Type'Val (1))  -- The first element of A

rather than

   A (1)  -- The element of A at the position corresponding to 1

Probably, the language should have a special syntax for that. Beloved []
brackets could suffice for the job:

   A [<universal-integer>]

could denote the array element by its position rather than by the index.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2012-02-29 20:07 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 20:15 Array Help? Will
2012-02-28 20:47 ` Ludovic Brenta
2012-02-28 22:11   ` Simon Wright
2012-02-28 23:09     ` Will
2012-02-29  0:24   ` Adam Beneschan
2012-02-28 20:50 ` Gautier write-only
2012-02-28 21:33 ` Simon Wright
2012-02-29  0:27   ` Adam Beneschan
2012-02-29  8:00     ` Simon Wright
2012-02-29  8:48       ` Simon Wright
2012-02-29  0:22 ` Adam Beneschan
2012-02-29 16:09   ` Robert A Duff
2012-02-29 16:50     ` Ludovic Brenta
2012-02-29 18:24       ` Robert A Duff
2012-02-29 19:45         ` stefan-lucks
2012-02-29 20:45           ` Jeffrey Carter
2012-02-29 21:27             ` stefan-lucks
2012-02-29 23:06           ` Robert A Duff
2012-03-02 13:45             ` stefan-lucks
2012-03-07 23:58             ` Randy Brukardt
2012-03-08 11:20               ` stefan-lucks
2012-03-09  2:02                 ` Randy Brukardt
2012-03-09  8:48                   ` stefan-lucks
2012-03-09 21:10                     ` Randy Brukardt
2012-03-15  2:55                     ` BrianG
2012-03-15  7:46                       ` stefan-lucks
2012-02-29 20:07         ` Dmitry A. Kazakov [this message]
2012-02-29 23:15           ` Robert A Duff
2012-03-01  8:54             ` Dmitry A. Kazakov
2012-03-01 14:06               ` Robert A Duff
2012-02-29 20:47         ` Simon Wright
2012-02-29 22:23           ` Robert A Duff
2012-02-29 23:27             ` Robert A Duff
2012-03-01  0:53               ` Adam Beneschan
2012-03-01  7:16               ` Ludovic Brenta
2012-03-01 14:03                 ` Robert A Duff
2012-03-08  0:11                   ` Randy Brukardt
2012-03-08  0:08               ` Randy Brukardt
2012-02-29 23:30             ` Simon Wright
2012-02-29 18:35     ` Jeffrey Carter
2012-02-29 22:59       ` Robert A Duff
2012-02-29 23:51         ` Jeffrey Carter
2012-03-01  3:03           ` Robert A Duff
2012-02-29 20:40     ` Adam Beneschan
replies disabled

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