comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Ada.Storage_IO. Anyone use it?
Date: Sat, 09 Jun 2012 16:09:25 +0200
Date: 2012-06-09T16:09:26+02:00	[thread overview]
Message-ID: <4fd35916$0$9517$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <xrv7mdjuf9cy.18s52ncomlpae$.dlg@40tude.net>

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.



  reply	other threads:[~2012-06-09 14:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a09e06d1-716f-4e3b-926b-55144f20d35a@googlegroups.com>
2012-06-09  8:36 ` Ada.Storage_IO. Anyone use it? Dmitry A. Kazakov
2012-06-09 14:09   ` Georg Bauhaus [this message]
2012-06-09 14:24 ` anon
2012-06-09  8:18 Micronian Coder
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox