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,1054df2e2c490eda X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Q: Memory management Date: 1996/06/27 Message-ID: #1/1 X-Deja-AN: 162352052 references: organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-06-27T00:00:00+00:00 List-Id: In article , Hannes Haug wrote: >I think I didn't understand the concept uf unconstrained arrays. There >are no constrained arrays. All arrays are constrained. All array *objects* are constrained. >... So there is no >need to store bounds somewhere in the array's storage. But there are >pointers that can point to arbitrary constrained arrays. But Pointer.all >is still constrained. That the bounds are not known at compile time is not >the fault of Pointer.all but of Pointer. So the storage for the bounds >belongs to Pointer and not to Pointer.all. So Pointer.all'Address should >be the address of the elements of the array. Is this view (at least logically) >correct ? Well, sort of, but not really. You're mixing implementation issues and semantic issues. Either implementation model is correct -- store the bounds with the pointer, or store the bounds with every aliased object. Aliased objects are the ones you can point at, including heap objects. Either way, 'Address should point to the first element of the array -- this is because the RM says so, not because of your arguments above about how it should naturally be implemented. Storing the bounds with the array could be done in (at least) two ways -- the access value could point at the bounds, or at the data (with the bounds being accessed at a negative offset). If the former, then Ptr.all'Address would be implemented as an ADD instruction, adding some constant number (the size of the dope) to the value of Ptr. Note that storing the bounds with the pointer is probably easiest to implement if you actual store the *address* of the bounds with the pointer. That is, an access type consists of a pair of addresses, one of which points to the bounds, and the other of which points at the data. (Only if the designated subtype is an unconstrained array, of course.) I don't like this implementation much, myself, for various reasons. Lots of other variations are possible. Ada does not require that access values be implemented as machine addresses. - Bob