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=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5161d10d9a4706fe X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.196.232 with SMTP id ip8mr2801762pbc.6.1339250982576; Sat, 09 Jun 2012 07:09:42 -0700 (PDT) Path: l9ni33869pbj.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 09 Jun 2012 16:09:25 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada.Storage_IO. Anyone use it? References: In-Reply-To: Message-ID: <4fd35916$0$9517$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 09 Jun 2012 16:09:26 CEST NNTP-Posting-Host: 67958c8b.newsspool1.arcor-online.net X-Trace: DXC=PHY9I1^31cYmG86`U=_nC_ic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@PFMP^6DDEk_WPCY\c7>ejVX[f6O@?Qkc]W\QVHKBPnS_Z X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-06-09T16:09:26+02:00 List-Id: On 09.06.12 10:36, Dmitry A. Kazakov wrote: > On Sat, 9 Jun 2012 01:06:35 -0700 (PDT), Micronian Coder wrote: > >> I was looking through the Ada RM and came across the generic package >> Ada.Storage_IO. I'm not sure what the benefits are to using it. It states >> that it could automatically flatten out the data representation if >> necessary. For example, say a discriminant record has an array field that >> is sized based on the discriminant value: >> >> type Buffer(Length : Positive) is >> record >> Bytes: Byte_Array(1 .. Length); >> end record; > > You cannot instantiate Ada.Storage_IO with this type, because Buffer is > indefinite. But since Ada.Storage_IO look totally useless (see A.9(11), > too!) anyway... Ada.Storage_IO is as useful or useless as the other traditional *_IO packages. For an example of usefulness, I can declare one or any number of Buffer_Type objects to put items on hold that were just read form a file ("ungetc"), or will be written to another file when some condition becomes true. Or, more generally, I can use Ada.Storage_IO for in-memory buffering *without* leaving the traditional IO framework. Like when sorting with three "tapes". The formal Element_Type is definite, but discriminated records might still work just fine, with defaults. A wrapped array of bytes with implementation-defined Positive'Last being the maximum number of elements seems an unnatural example for use with traditional *_IO packages. For other types such as database records, or anything that isn't a huge in-memory representation of the universe and everything, Ada.Storage_IO should be fine. type Count is range 0 .. 400; type List_Of_Things is array (Count range <>) of T; type Item_to_Store (Length: Count := 42) is record Things : List_of_Things (1 .. Length); end record; There are compilers that do have a working implementation of Ada.Storage_IO.