From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1fd537a3da8a5021 X-Google-Attributes: gid103376,public From: Michael Carman Subject: Re: Array access via pointer? Date: 2000/08/02 Message-ID: <3988269B.D1DB4EA5@home.com>#1/1 X-Deja-AN: 653625166 Content-Transfer-Encoding: 7bit References: <398721AD.CAEE3A51@home.com> <8m7hn1$i4r$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: None (anarchist) Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-08-02T00:00:00+00:00 List-Id: 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 () 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