comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada.Storage_IO. Anyone use it?
Date: Sat, 9 Jun 2012 10:36:39 +0200
Date: 2012-06-09T10:36:39+02:00	[thread overview]
Message-ID: <xrv7mdjuf9cy.18s52ncomlpae$.dlg@40tude.net> (raw)
In-Reply-To: a09e06d1-716f-4e3b-926b-55144f20d35a@googlegroups.com

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...
 
> Did anyone find this package useful in practice rather than define their
> own IO routines (e.g. define stream operations to read and write their
> data)?

1. For specifically storage I/O I am using memory pools. Instead of Write I
do "new", instead of Read I use an access type. This is cleaner, more
efficient, and no generics involved.

   = Pool, backed by a container, e.g. a segmented memory stack

2. For data exchange I am using streams. I always redefine stream
operations because built-in ones are unusable for data exchange, which
dictates certain representation. Again, no generics, no any limitations of
elements, reusable with different stream backends.

   = Stream, backed by a container.

It is worth to mention that there are three major distinct cases, which get
permanently confused in the context of I/O:

A. Marshaling objects (true I/O, persistency, serialization)
B. Formatted I/O and rendering (dealing with human readable
representations)
C. Garbage collection of objects (e.g. arena allocators etc)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



       reply	other threads:[~2012-06-09  8:36 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 ` Dmitry A. Kazakov [this message]
2012-06-09 14:09   ` Ada.Storage_IO. Anyone use it? Georg Bauhaus
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