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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no 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!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!Spring.edu.tw!news.nctu.edu.tw!feeder.seed.net.tw!attdv1!ip.att.net!newsfeed1.global.lmco.com!svlnews.lmms.lmco.com!not-for-mail From: "Xenos" Newsgroups: comp.lang.ada Subject: Re: Zero length Objects Date: Thu, 1 Jul 2004 10:06:06 -0400 Organization: Hades Message-ID: References: <2kh2leF2ct4hU1@uni-berlin.de> NNTP-Posting-Host: 158.187.64.144 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Xref: g2news1.google.com comp.lang.ada:2026 Date: 2004-07-01T10:06:06-04:00 List-Id: "Nick Roberts" wrote in message news:2kh2leF2ct4hU1@uni-berlin.de... > "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. There was a long discussion about this in the Ada Comment list. > I hope Randy and Tucker are reading this thread, because it seems to add > fuel to my argument that the 'right' thing for a compiler to do is to allow > zero-size objects (and to perform zero-size allocation for them), and to > implement the access value mechanism I suggested. > > For the curious, the mechanism I suggested was that the compiler 'invents' > unique encodings for access values that reference zero-size objects. An > invented encoding can be any value that can be stored in an object of the > access type which is guaranteed never to be the same as any valid address > (or other invented value in scope), assuming the typical mechanism that an > access value which references a nonzero-size object is simply its address. > > This provides a way to preserve the 'uniqueness characteristic' of access > values, that if they designate different objects their values will be > different, without preventing the implementation of genuinely zero-size > objects (that do not take up any memory at all). > > I believe the uniqueness characteristic of access values should be inviolate > (because certain algorithms might depend on it), and that genuinely > zero-size objects (actually, zero-size types) are sometimes useful (in > generic instantiations). Randy and Tucker disagreed (or at least, they > didn't agree that the uniqueness characteristic should be mandated by the > standard for access values referencing zero-size objects). I live in hope. > > -- > Nick Roberts > > C++ has a similar rule that says an object cannot be zero bytes in size, but it does says that an empty (no data members) base class may be zero size within the inherited class. Does Ada have a similar rule to this? Meaning if I create a null record and derive a another record from it, will the null record take up zero space within the derived record? Sorry, if my terminology isn't exact for Ada, I a little new to the 95 standard.