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,b9880ab5a4975a57 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!transit.news.xs4all.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Object with zero bits Date: Wed, 13 Oct 2004 15:59:51 +0100 Message-ID: <2t4u78F1pl10vU1@uni-berlin.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de n2gQPncpeJhbxMOUFESB4A8C8k1x5X73YEkvO6/spyrB623Hc= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:5155 Date: 2004-10-13T15:59:51+01:00 List-Id: Robert C. Leif wrote: > For the Ada implementation of the binary data part of CytometryML, > I am using a discriminant to control a variant record where I need to > store an object with a zero storage size. Instead of null, I would > like a record with an object of 0 bits (Empty_Var). Why? (I guess the answer is to do with automated code generation.) > I have about 12 parameters and would like to be able to have the user > determine which ones he or she will store. Do you mean as components of one record type? > If all else fails, I can make a Boolean type that corresponds to > one bit in a 32 bit unsigned integer and simply consider this 32 bit > unsigned integer as excess baggage.. An array of Booleans could be packed (one bit each). You could probably squeeze 12 Booleans into a 16-bit array, and I think this would be highly portable. In fact, I think you would get away with squeezing such an array into 12 bits as a record (discriminant) component, on most compilers. > I do have the luxury that I can wait for Ada 2005. Will this > capacity be in Ada 2005? If so, is there an example? If you are referring to the ability to declare an object (component) of (genuinely) size 0, I don't think Ada 2005 is going to require compilers to support this, and I'm afraid you will have to expect many compilers not to. Most do not now (I've just tested GNAT, and it doesn't). As it happens, I intend to enable ECLAT to support zero size objects for most or all targets. > Another approach, which I am trying to avoid is to store the data > as a stream that contains different data-types. Why are you trying to avoid it? I suggest streams might be a (nearly) ideal solution. A custom Write procedure could be used to write out only the components which the user wishes to store, and a custom Input function could read the components which have been stored, and perhaps initialise the ones which have not. I'd be happy to illustrate this technique, if you wish. -- Nick Roberts