comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Array access via pointer?
Date: 2000/08/01
Date: 2000-08-01T00:00:00+00:00	[thread overview]
Message-ID: <8m7hn1$i4r$1@nnrp1.deja.com> (raw)
In-Reply-To: 398721AD.CAEE3A51@home.com

In article <398721AD.CAEE3A51@home.com>,
  Michael Carman <mjcarman@home.com> wrote:

> type Addr_Table is array (Natural range <>) of System.Address;
>
> Arr1 : Addr_Table (0 .. 100);
> Arr2 : Addr_Table (0 .. 20);
>
> procedure Foo (Addr : in System.Address;
>                I    : in Integer) is
> begin
>     -- Do something with index I of the array at Addr
> end Foo;

> fight against the language. So, what's the canonical way of doing
> this in Ada?

That would be:

procedure Foo (Addr : in out Addr_Table;
               I    : in     Integer) is
begin
   -- Do something with index I of the array at Addr
end Foo;

It may be much more constructive for you to tell us why you feel you
need to use addresses and pointers. In Ada you almost *never* have to
use addresses, and rarely have to use pointers. Unless you have an
actual dynamic or linked data structure, or are interfacing to some
external C or OS call, you are probably doing something wrong when you
write code with addresses and/or pointers in it.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-08-01  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-01  0:00 Array access via pointer? Michael Carman
2000-08-01  0:00 ` Ted Dennison [this message]
2000-08-02  0:00   ` Michael Carman
2000-08-03  0:00     ` Ken Garlington
2000-08-03  0:00       ` Robert A Duff
2000-08-03  0:00         ` Ken Garlington
2000-08-04  0:00           ` Robert I. Eachus
2000-08-04  0:00             ` Ken Garlington
2000-08-02  0:00 ` Markku Kotiaho
2000-08-02  0:00 ` tmoran
2000-08-02  0:00   ` Michael Carman
2000-08-02  0:00     ` tmoran
replies disabled

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