comp.lang.ada
 help / color / mirror / Atom feed
From: John Perry <john.perry@usm.edu>
Subject: Re: surprise data from Ada.Sequential_IO
Date: Mon, 22 Mar 2021 11:14:13 -0700 (PDT)	[thread overview]
Message-ID: <becc53b7-4e93-4d6b-8202-df8165ecbeedn@googlegroups.com> (raw)
In-Reply-To: <s3akql$hln$1@dont-email.me>

Jeff & Dmitry

On Monday, March 22, 2021 at 12:40:39 PM UTC-5, Jeffrey R. Carter wrote:
> On 3/22/21 6:13 PM, John Perry wrote: 
> > The following worked as expected (sorry for the abbreviations but I think it will be clear): 
> > 
> >>> P1.Create; P1.Write; P1.Close; P2.Open(Append_File); P2.Write; P2.Close;
> This is asking for trouble,
> > 
> > However, this: 
> > 
> >>> P3.Open(Append_File); P3.Write; P3.Close; 
> > 
> > ...wrote a few bytes of junk between T2's data and T3's data.
> which you got. 

Thank you, I got a laugh out of that :-)

> When you open a P3.File_Type with mode Append_File, it expects the file to 
> contain an integral number of values of T3 already. What happens if it doesn't 
> appears to be undefined. 

For Direct_IO I inferred this fact from ARM A.8.3, "the file is viewed as a set of elements occupying consecutive positions in linear order", but I don't see a similar indication for Sequential_IO. Is there a warning in the ARM about this?

(I do see the warning in Barnes' book, which I had consulted! and saw! and decided not to use Direct_IO as a result! but somehow read the same thing about Sequential_IO & either forgot or mis-concluded something. So I acknowledge my stupidity here.)

> Either create a record with components of the the three types, instantiate 
> Sequential_IO for that, and write all three values at once, or use streams for 
> heterogeneous I/O. 

I'll look into Streams, thanks.

john perry

  reply	other threads:[~2021-03-22 18:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 17:13 surprise data from Ada.Sequential_IO John Perry
2021-03-22 17:40 ` Jeffrey R. Carter
2021-03-22 18:14   ` John Perry [this message]
2021-03-22 19:41     ` Jeffrey R. Carter
2021-03-22 20:54       ` Niklas Holsti
2021-03-23  9:18         ` Jeffrey R. Carter
2021-03-22 21:25       ` Shark8
2021-03-22 17:48 ` Dmitry A. Kazakov
replies disabled

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