From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!petunia!nwebre@ucbvax.Be rkeley.EDU (Neil Webre)
Subject: Re: What should this do?
Date: 2 Jul 91 17:09:02 GMT [thread overview]
Message-ID: <2870b32e.58b0@polyslo.CalPoly.EDU> (raw)
You might use the following program to get a glimpse of what your Ada system
is doing with mutable records. It's not completely definitive but gives a
good clue. Sorry for the global variables - this is one off quick and
dirty.
PS to Mike Feldman - Re your question on what Alsys does in this case.
This was run on Alsys Ada on AIX/370, IBM 3090/400. It appears that they
allocate maximum space (20 bytes) and have the string bob about in it.
Good for speed, bad for space utilization
-- Check Alsys techniques for mutable records.
with text_io; use text_io;
with system; -- Alsys version has a procedure "image" that makes
-- addresses into strings.
procedure main is
subtype index is integer range 0..20;
type rec(len : index := 0) is record
data : string(1..len);
end record;
S : rec;
procedure print is
begin
put_line("S's address is " & system.image(S'address) & " hex");
put_line("For S.len =" & integer'image(S.len) & ',' &
integer'image(S'size/8) & " bytes are used."); new_line;
end print;
begin
S := (0, "");
print;
S := (10,"0123456789");
print;
S := (20,"01234567890123456789");
print;
S := (0,"");
print;
end main;
Results of execution:
S's address is 0024BAFC hex
For S.len = 0, 7 bytes are used.
S's address is 0024BAFC hex
For S.len = 10, 17 bytes are used.
S's address is 0024BAFC hex
For S.len = 20, 27 bytes are used.
S's address is 0024BAFC hex
For S.len = 0, 7 bytes are used.
Neil Webre
Cal Poly, San Luis Obispo, CA
Department of Computer Science.
next reply other threads:[~1991-07-02 17:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-07-02 17:09 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!petunia!nwebre [this message]
-- strict thread matches above, loose matches on Subject: below --
1991-07-02 13:06 What should this do? Fred Stluka
1991-07-01 15:21 voder!wlbr!lonex.radc.af.mil!blackbird.afit.af.mil!dlindsle
1991-07-01 12:45 CBW Consulting
1991-06-28 19:35 David T. Lindsley
1991-06-28 21:40 ` Howard Turner
1991-06-29 0:31 ` Jim Showalter
1991-06-29 16:44 ` Michael Feldman
1991-06-29 21:22 ` Jim Showalter
1991-06-29 5:52 ` rharwood
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox