comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Ada.Storage_IO: applied example?
Date: Tue, 23 Oct 2012 14:21:21 -0700 (PDT)
Date: 2012-10-23T14:21:21-07:00	[thread overview]
Message-ID: <02c1ae27-d859-42de-b69d-1c0b5159e99d@googlegroups.com> (raw)
In-Reply-To: <op.wmngg50vule2fv@cardamome>

On Tuesday, October 23, 2012 1:57:02 PM UTC-7, Hibou57 (Yannick Duchêne) wrote:
> Le Tue, 23 Oct 2012 22:28:34 +0200, Dmitry A. Kazakov  

> >> I'm seeking for a tiny use case showing `Ada.Storage_IO` in action.
> > It looks useless at first glance.
> 
> Yes, indeed, it looks, lol. That's precisely the reason why I opened this  
> topic. I would hardly believe something that usefulness belongs to the  
> standard packages, so I guess I am missing something, and would like to  
> learn what it is. Is this a kind of holder container?
> 
> > The buffer size is fixed and implementation defined(!).
> 
> It's implementation defined, but not “randomly”: the size correspond to  
> the count of storage elements (it self, implementation defined) required  
> to store an instance of the element type which is the parameter of the  
> generic package. That's implementation defined, but predictable.

Looking at the AARM, it appears that the main reason this might be useful is you've defined a record type that contains a hidden pointer (i.e. a pointer that the Ada implementation sets up, not a subcomponent of an access type).  In that case, the buffer contains the "flattened" version of the data.  E.g.

   type Rec is record
     S : String (1 .. Name_Size);
     ... other components
   end record;

where Name_Size is non-static object (i.e. the value can't be determined at compile time).  Some implementations (but not GNAT, I believe) would store S as a pointer, rather than fool around with Rec objects whose size isn't known at compile time, and possibly components whose location in the record isn't known at compile time.  In this case, you couldn't rely on Rec'Size (or Rec'Size / System.Storage_Unit) to be large enough to contain all the data; I think that's the kind of case where the language designers thought this would be useful, because you could write code that would work with any Ada implementation.  Still, you should be able to accomplish the same thing using the stream features of Ada, and I think that would be preferable.

                           -- Adam



  reply	other threads:[~2012-10-23 21:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 19:42 Ada.Storage_IO: applied example? Yannick Duchêne (Hibou57)
2012-10-23 20:28 ` Dmitry A. Kazakov
2012-10-23 20:56   ` Yannick Duchêne (Hibou57)
2012-10-23 21:21     ` Adam Beneschan [this message]
2012-10-23 21:02   ` Jeffrey Carter
2012-10-24  7:20     ` Dmitry A. Kazakov
2012-10-24  5:03   ` J-P. Rosen
2012-10-24  7:34     ` Dmitry A. Kazakov
2012-10-24  9:49       ` AdaMagica
2012-10-24 10:28         ` Dmitry A. Kazakov
2012-10-24 11:51           ` Yannick Duchêne (Hibou57)
2012-10-24 12:27             ` Dmitry A. Kazakov
2012-10-24 14:03             ` Georg Bauhaus
replies disabled

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