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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,58331d88725b914e,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!proxad.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: "Robert C. Leif" Newsgroups: comp.lang.ada Subject: for Object_Size use 0 Date: Tue, 12 Apr 2005 18:52:07 -0700 Organization: Newport Instruments Message-ID: Reply-To: rleif@rleif.com NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1113357148 33381 212.85.156.195 (13 Apr 2005 01:52:28 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Wed, 13 Apr 2005 01:52:28 +0000 (UTC) To: "Comp. Lang. Ada" Return-Path: X-Authenticated-User: rleif.rleif.com X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcU/yzpoP1BWnHTgScaMuR12O3kdPA== X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:10404 Date: 2005-04-12T18:52:07-07:00 To: the Readers of Comp.Lang.Ada I have been working for about two years to produce a program that stores the values of one or more selected parameters of a group of parameters. This work has been published (R. C. Leif, CytometryML, Binary Data Standards, in Manipulation and Analysis of Biomolecules, Cells, and Tissues II, D. V. Nicolau, J. Enderlein, R. C. Leif, and D. Farkas, Editors, SPIE Proceeding Vol. 5699 pp. 325-333 (2005).(Preprint at http://newportinstruments.com/cytometryml/pdf/CytometryML_Bin_Data_Stds28Jan 05.pdf) Since Ada was new to this audience and this was not a software engineering paper, I limited the amount of Ada source. Therefore, it might be desirable to submit a paper on this use of Ada to SIGAda 2005. However, the software in this paper would have been much simpler and more reliable, if a variant record with a discriminant set to false resulted in an object that used no storage space. This peculiar requirement for the use of 0 storage space is based on the creation of a binary data standard that produces files that can be read and written by multiple programming languages. One way to facilitate testing of this software is to create files that are based on arrays of records with a fixed simple, constant format. A simple efficient fixed format is to have the data from each parameter in a fixed sequence without any spaces. Thus, a record containing multiple selected parameters would look like the binary representation of the following with the spaces omitted: 1 500 25_000 1.0 10_000 0.5 The number of elements in the data array or file ranges between 5,000 and 100 million. The example below includes a variant record with a single parameter. The actual usage would have between 1 and 100 parameters. I specifically need to know if it is possible to create a zero sized type in Ada 95 or the updated standard, which is to be released in the near future. Thank you. Bob Leif --------------------------------------------------------- -- This is a test of whether Ada can have a type with a size of 0 bits. -- This type is needed to permit the use of a variant record -- as a means of not including a parameter. with Ada.Text_IO; procedure Empty_Pkg is package T_IO renames Ada.Text_IO; type Empty_Type is (Empty); for Empty_Type'Object_Size use 0; Empty_Var : Empty_Type := Empty; type Byte_Type is mod 256; -- an unsigned byte for Byte_Type'Object_Size use 8; Byte : Byte_Type := 255; subtype Fl_520_540_Type is Natural; -- Fl_520_540 is the fluorescence emission between 520 and 540 -- nanometers. type Fl_520_540_Or_Null_Rec_Type (Stored : Boolean := False) is record case Stored is when True => Fl_520_540_Part : Fl_520_540_Type := 0; when False => null; end case; end record; Fl_520_540_Or_Null_Rec : Fl_520_540_Or_Null_Rec_Type (Stored => False); type Fl_520_540_Or_Empty_Rec_Type (Stored : Boolean := False) is record case Stored is when True => Fl_520_540_Part : Fl_520_540_Type := 0; when False => Empty_Part : Empty_Type := Empty; end case; end record; Fl_520_540_Or_Empty_Rec : Fl_520_540_Or_Empty_Rec_Type (Stored => False); type Fl_520_540_Or_Byte_Rec_Type (Stored : Boolean := False) is record case Stored is when True => Fl_520_540_Part : Fl_520_540_Type := 0; when False => Byte_Part : Byte_Type := 255; end case; end record; Fl_520_540_Or_Byte_Rec : Fl_520_540_Or_Byte_Rec_Type (Stored => False); function Size ( Empty : Empty_Type) return Integer is begin return Empty'Size; end Size; function Size ( Byte : Byte_Type) return Integer is begin return Byte'Size; end Size; function Size (Fl_520_540_Or_Null_Rec : Fl_520_540_Or_Null_Rec_Type) return Integer is begin return Fl_520_540_Or_Null_Rec'Size; end Size; begin -- T_Io.Put_Line("The size of null is " & Integer'Image(null'Size)); T_IO.Put_Line ("The Empty'Size is " & Integer'Image (Empty_Var'Size)); T_IO.Put_Line ("The Byte'Size is " & Integer'Image (Byte'Size)); T_IO.Put_Line (" "); T_IO.Put_Line ("The Size(Empty) is " & Integer'Image (Size (Empty))); T_IO.Put_Line ("The Size(Byte) is " & Integer'Image (Size (Byte))); T_IO.Put_Line (" "); T_IO.Put_Line ("The size of the Fl_520_540_or_Empty_Rec is " & Integer'Image(Fl_520_540_Or_Empty_Rec'Size)); T_IO.Put_Line ("The size of the Fl_520_540_or_Null_Rec is " & Integer'Image (Fl_520_540_Or_Null_Rec'Size)); T_IO.Put_Line ("The Size (Fl_520_540_or_Null_Rec) is " & Integer'Image (size(Fl_520_540_Or_Null_Rec))); T_IO.Put_Line ("The size of the Fl_520_540_or_Byte_Rec is " & Integer'Image (Fl_520_540_Or_Byte_Rec'Size)); T_IO.Put_Line (" "); end Empty_Pkg; --------------------------------------------------------------- Output of GNAT compiled with -gnatR0 -O2 (or O3) 1 AD: executable=.\Empty_Pkg.exe The Empty'Size is 8 The Byte'Size is 8 The Size(Empty) is 8 The Size(Byte) is 8 The size of the Fl_520_540_or_Empty_Rec is 64 The size of the Fl_520_540_or_Null_Rec is 32 The Size (Fl_520_540_or_Null_Rec) is 32 The size of the Fl_520_540_or_Byte_Rec is 64 Program exited normally.