From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: surprise data from Ada.Sequential_IO Date: Mon, 22 Mar 2021 22:54:22 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net mMr7Wqqce+lXH7/G7s90VgWWx8OAvcsGCTy6fcnu21RsjYvvFk Cancel-Lock: sha1:XkrPCTGyuTvRD3LJTZpc7xvL670= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61643 List-Id: On 2021-03-22 21:41, Jeffrey R. Carter wrote: > The only differences between Direct_IO and Sequential_IO are that > Direct_IO allows random access and mixed input and output. In both cases > the file contains a sequence of binary representations of values of a > single type. > > I don't really understand why Sequential_IO exists, since Direct_IO > provides a superset of Sequential_IO's functionality. Not quite. From the RM: generic type Element_Type is private; package Ada.Direct_IO is ... and generic type Element_Type(<>) is private; package Ada.Sequential_IO is ... So Sequential_IO allows unknown discriminants in the element type, in other words elements that can vary in size, which obviously hampers random (indexed) access to elements in the file, which Direct_IO allows. There is also this note for Direct_IO: RM A.8.4(19.a): Reason: The Element_Type formal of Direct_IO does not have an unknown_discriminant_part (unlike Sequential_IO) so that the implementation can make use of the ability to declare uninitialized variables of the type.