From: Michael Carman <mjcarman@home.com>
Subject: Re: Array access via pointer?
Date: 2000/08/02
Date: 2000-08-02T00:00:00+00:00 [thread overview]
Message-ID: <3988269B.D1DB4EA5@home.com> (raw)
In-Reply-To: 8m7hn1$i4r$1@nnrp1.deja.com
Ted Dennison wrote:
>
> procedure Foo (Addr : in out Addr_Table;
> I : in Integer) is
> begin
> -- Do something with index I of the array at Addr
> end Foo;
Yes, that's much cleaner, thank you. Is it safe to assume that
internally Addr_Table is passed by reference? (It's a bit more data than
I want on the stack.)
> It may be much more constructive for you to tell us why you feel you
> need to use addresses and pointers.
> [...]
Which pointers -- the ones to my arrays or the ones inside them? :) I
assure you that the latter are necessary; they tell me where to find
data from an external process. I'd happily get rid of the former ones,
though.
My example was simplified to illustrate the problem I was having.
Unfortunately, it oversimplified the situation a bit. I wasn't passing
in a pointer to an array just for fun. I determine which array to
process in a completely seperate part of the program. That is, I don't
actually call Foo() this way:
Foo(Arr2'Address, 7);
I have some higher-up logic that's something like this:
if (<condition>) then
Arr_Ptr := Arr1'Address;
else
Arr_Ptr := Arr2'Address;
end if;
Deeper down, in a completely seperate part of things, I call
Foo(Arr_Ptr, 7);
So the later code is fat, dumb and happy, knowing nothing about the
earlier logic. Your example passing Addr_Table instead of a pointer is
great, but I need to keep this functionality. Is there a way to alias
variables such that I can set "My_Array := Arr2" (without actually
creating a copy)? All I've been able to find is defining aliased
variables, and then using access types to get to them, which puts me
back in the pointer/dereference boat.
[To further complicate things, I can't use 'Access -- I'm trying to keep
my code Ada83 compatible -- I know how to work around it, it's just
messier.]
Of course, that's still better than what I'm currently doing.
-mjc
next prev parent reply other threads:[~2000-08-02 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
2000-08-02 0:00 ` Michael Carman [this message]
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