comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: xor
Date: Wed, 28 Mar 2012 23:48:35 +0200
Date: 2012-03-28T23:48:35+02:00	[thread overview]
Message-ID: <4f738733$0$6637$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <tdadna1MV6uj5O7SnZ2dnUVZ_jidnZ2d@earthlink.com>

On 28.03.12 22:49, Dennis Lee Bieber wrote:
> On Wed, 28 Mar 2012 18:36:28 +0100, Michael Moeller<mic2@t-online.de>
> declaimed the following in comp.lang.ada:
>
>
>> I see. Alas, none of my books or manuals even mentions binary file I/O.
>
> 	Maybe because anything that is NOT derived from Text_IO is
> considered to be Binary.

(Or, maybe, because prior to Unix, the somewhat simplistic
distinction  "r"/"b" wasn't that popular? Structured files
being offered by the operating systems, IINM.)

In any case, traditional Ada I/O (other than Text_IO) is
focusing on types:

Let an object be of some type T.  If you want that object
to be input or output, instantiate an I/O module for
type T, and there you go, inputting and outputting objects
of type T using subprograms from the instance.

For I/O of a mix of types ("binary" I/O), streams come in handy.
Again, the mechanism focuses on types: every type is associated
with two pairs of functions:

   T'Read      T'Write
   T'Input     T'Output

Roughly speaking, the first pair writes bare data (representations),
the second pair adds more "administrative" information about the
type T. There is a guarantee about what they do. When a program
outputs an object of type T using one function, then the corresponding
function can input the object of type T, and vice versa.
(I guess that this is some form of idempotence, however, I should
leave this to the mathematicians.)

The above functions' profiles consist of a pointer to an object of
some stream type, and an object of type T, to be read, or written.

Somewhat internally, every stream type has two (primitive) subprograms
again called Read and Write. These can implement the data transmission
layer of the streaming functions mentioned above; they operate in
terms of Storage_Element_Array. That's the binary layer, so to speak.
They are similar to Unix's read(2) and write(2) calls.
Subprograms taking Storage_Element_Array parameters operate at the
same level as subprograms related to "sequence of bytes" in the
C sense (I would say so). You can use these when implementing your
own streaming functions, or when you have data suitable for a "cast",
so that the bits are re-interpreted as Storage_Element_Array
(through an instance of Ada.Unchecked_Conversion).

If it interests you, there is

http://www.adaic.org/learn/materials/

Ada 95 material is fine, too, insofar as recent changes to the
language are mostly non-destructive.



  parent reply	other threads:[~2012-03-28 21:49 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-25 14:28 xor Michael Moeller
2012-03-25 14:01 ` xor Niklas Holsti
2012-03-25 15:16   ` xor Michael Moeller
2012-03-25 19:05     ` xor Dmitry A. Kazakov
2012-03-27 20:31       ` xor Michael Moeller
2012-03-25 19:26     ` xor Niklas Holsti
2012-03-27 20:09       ` xor Michael Moeller
2012-03-27 19:44         ` xor Dmitry A. Kazakov
2012-03-27 21:16           ` xor Michael Moeller
2012-03-27 21:14             ` xor Simon Wright
2012-03-27 22:56               ` xor Michael Moeller
2012-03-27 22:03             ` xor Georg Bauhaus
2012-03-27 23:50               ` xor Michael Moeller
     [not found]                 ` <bbedne9wdofZyu_SnZ2dnUVZ_hydnZ2d@earthlink.com>
2012-03-28 12:18                   ` xor Michael Moeller
2012-03-28 12:48                     ` xor Georg Bauhaus
2012-03-28 15:23                       ` xor Michael Moeller
2012-03-28 15:58                         ` xor Niklas Holsti
2012-03-28 17:28                           ` xor Michael Moeller
2012-03-28 23:25                           ` xor Randy Brukardt
2012-03-29  5:17                             ` xor Niklas Holsti
2012-03-29 23:41                               ` xor Randy Brukardt
2012-03-30 21:53                                 ` xor Niklas Holsti
     [not found]                         ` <jtmdnfjWWsUYoO7SnZ2dnUVZ_gSdnZ2d@earthlink.com>
2012-03-28 17:44                           ` xor Michael Moeller
2012-03-28 14:07                     ` xor Dmitry A. Kazakov
2012-03-28 16:16                       ` xor Michael Moeller
2012-03-28 16:08                         ` xor Dmitry A. Kazakov
2012-03-28 17:36                           ` xor Michael Moeller
     [not found]                             ` <tdadna1MV6uj5O7SnZ2dnUVZ_jidnZ2d@earthlink.com>
2012-03-28 21:48                               ` Georg Bauhaus [this message]
2012-03-29  7:43                               ` xor Dmitry A. Kazakov
2012-03-29  7:49                               ` xor Simon Wright
2012-03-27 21:28           ` xor Georg Bauhaus
2012-03-27 19:50         ` xor Randy Brukardt
2012-03-27 21:44           ` xor Michael Moeller
2012-03-27 22:01             ` xor Georg Bauhaus
2012-03-27 20:13         ` xor Jeffrey Carter
replies disabled

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