comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Record component positions always constant?
Date: 1996/05/26
Date: 1996-05-26T00:00:00+00:00	[thread overview]
Message-ID: <dewar.833130595@schonberg> (raw)
In-Reply-To: 4o9h6c$3rk@goanna.cs.rmit.EDU.AU


Dale asked:

"Will the positions of the components in a record (for a given
subtype) remain constant even in the presence of fields whose
lengths depend on a discriminant (excluding of course variant
records) for all (likely) Ada implementations?"

The answer is NO for all likely Ada implementations, a subtype is
required to take only as much space as it needs. One can imagine
an imlementatoin that uses hidden heap pointers for variable length
components depending on discriminants, but in practice virtually all
(all?) implementations store the variable length field in place. Some
implementations store extra offset components to help them find their
way past such components (old Alsys technology does this in the absence
of some pragma (I forget the details of he pragma). Other implementations
(Dec, GNAT, Alsys with that pragma), recompute their way past the
variable length fields from the discriminant values on each reference.

To give a very specific example:

   type R (N : Natural) is record
      S1 : String (1 .. N);
      S2 : String (1 .. N);
   end record;

the offset of component S2 will typically vary with the value of N.

There is an ACVC test that ensures that no implementation uses
allocate-the-maximum for such individual fields.





      reply	other threads:[~1996-05-26  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-26  0:00 Record component positions always constant? Dale Stanbrough
1996-05-26  0:00 ` Robert Dewar [this message]
replies disabled

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