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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,85c4b961f840b5ab X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!news.cs.univ-paris8.fr!informatik.uni-bremen.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Zero length Objects Date: Thu, 1 Jul 2004 01:28:02 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <2kh2leF2ct4hU1@uni-berlin.de> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1088645282 28505 134.91.1.34 (1 Jul 2004 01:28:02 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Thu, 1 Jul 2004 01:28:02 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: g2news1.google.com comp.lang.ada:2015 Date: 2004-07-01T01:28:02+00:00 List-Id: Nick Roberts wrote: : "Frank J. Lhota" 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