From: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de>
Subject: Re: Zero length Objects
Date: Thu, 1 Jul 2004 01:28:02 +0000 (UTC)
Date: 2004-07-01T01:28:02+00:00 [thread overview]
Message-ID: <cbvpb2$rqp$1@a1-hrz.uni-duisburg.de> (raw)
In-Reply-To: 2kh2leF2ct4hU1@uni-berlin.de
Nick Roberts <nick.roberts@acm.org> wrote:
: "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net> wrote in message
: news:PSFEc.50650$aJ3.17580@nwrdny02.gnilink.net...
:
:> No object is really of zero length. The reason is that every object should
:> have a unique address. Therefore, most Ada compilers will allocate at
: least
:> one storage element to each object, in order to insure that if we declare
:>
:> A, B : Empty_Type;
:>
:> then A and B do not both refer to the same location.
:
: Yes indeed.
One might add that the full story has zero size things if not
objects:
with Ada.Text_IO;
procedure sz is
type Nothing is null record;
for Nothing'size use 0;
type What is record
thing: Natural := 1_000_000;
more: Nothing;
end record;
type Then_Again is record
uhm: Nothing;
end record;
package TIO renames Ada.Text_IO;
x: What;
y: Then_Again;
begin
TIO.put_line("size of Natural: " & Natural'image(Natural'size));
TIO.put_line("size of x of type What: " & Natural'image(x'size));
TIO.put_line("size of y of type Then_Again: " & Natural'image(y'size));
end sz;
$ ./sz
size of Natural: 31
size of x of type What: 32
size of y of type Then_Again: 8
$
So the size of the .more component is no greater than 1, I think.
Georg
next prev parent reply other threads:[~2004-07-01 1:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-30 5:55 Zero length Objects Robert C. Leif
2004-06-30 20:32 ` Jacob Sparre Andersen
2004-06-30 21:01 ` Frank J. Lhota
2004-07-01 0:02 ` Nick Roberts
2004-07-01 1:28 ` Georg Bauhaus [this message]
2004-07-01 10:37 ` Björn Persson
2004-07-01 11:25 ` Larry Kilgallen
2004-07-01 14:11 ` Nick Roberts
2004-07-01 15:42 ` Larry Kilgallen
2004-07-01 14:06 ` Xenos
2004-07-01 15:26 ` Nick Roberts
2004-07-02 1:06 ` Jeffrey Carter
2004-07-01 0:47 ` Brian May
2004-07-01 13:32 ` Frank J. Lhota
2004-07-01 14:52 ` Nick Roberts
2004-07-01 15:03 ` Xenos
2004-07-01 15:57 ` Hyman Rosen
2004-07-01 16:05 ` Xenos
2004-07-02 15:02 ` Frank J. Lhota
2004-07-02 15:11 ` Adrian Knoth
2004-07-02 15:43 ` Frank J. Lhota
2004-07-02 19:01 ` Vinzent 'Gadget' Hoefler
2004-07-02 19:07 ` Adrian Knoth
2004-07-02 19:25 ` Vinzent 'Gadget' Hoefler
2004-07-02 21:06 ` Xenos
2004-07-02 21:56 ` Vinzent 'Gadget' Hoefler
-- strict thread matches above, loose matches on Subject: below --
2004-07-02 8:30 Christoph Karl Walter Grein
2004-07-06 11:59 ` Nick Roberts
2004-07-06 22:14 ` Randy Brukardt
2004-07-06 22:28 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox