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!news1.google.com!news.glorb.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Zero length Objects Date: Thu, 1 Jul 2004 01:02:53 +0100 Message-ID: <2kh2leF2ct4hU1@uni-berlin.de> References: X-Trace: news.uni-berlin.de qtzefWsGQL8xHYuvfaD+BQjrujH4M1imVaV67Ld5kVhtlQKQA= 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:2013 Date: 2004-07-01T01:02:53+01:00 List-Id: "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