A.8 Sequential and Direct Files
Static Semantics
1/2
{
AI95-00283-01} 
Two 
kinds of access to external files are defined in this subclause: 
sequential 
access and 
direct access. The corresponding file types and 
the associated operations are provided by the generic packages Sequential_IO 
and Direct_IO. A file object to be used for sequential access is called 
a 
sequential file, and one to be used for direct access is called 
a 
direct file. Access to 
stream files stream 
files is described in 
A.12.1.
 
2
For sequential access, the file 
is viewed as a sequence of values that are transferred in the order of 
their appearance (as produced by the program or by the external environment). 
When the file is opened with mode In_File or Out_File, transfer starts 
respectively from or to the beginning of the file. When the file is opened 
with mode Append_File, transfer to the file starts after the last element 
of the file. 
 
2.a
Discussion: Adding stream I/O necessitates 
a review of the terminology. In Ada 83, `sequential' implies both the 
access method (purely sequential — that is, no indexing or positional 
access) and homogeneity. Direct access includes purely sequential access 
and indexed access, as well as homogeneity. In Ada 95, streams allow 
purely sequential access but also positional access to an individual 
element, and are heterogeneous. We considered generalizing the notion 
of `sequential file' to include both Sequential_IO and Stream_IO files, 
but since streams allow positional access it seems misleading to call 
them sequential files. Or, looked at differently, if the criterion for 
calling something a sequential file is whether it permits (versus requires) 
purely sequential access, then one could just as soon regard a Direct_IO 
file as a sequential file.
2.b
It seems better to regard `sequential file' 
as meaning `only permitting purely sequential access'; hence we have 
decided to supplement `sequential access' and `direct access' with a 
third category, informally called `access to streams'. (We decided against 
the term `stream access' because of possible confusion with the Stream_Access 
type declared in one of the stream packages.)
3
For 
direct access, the file is viewed as a set of elements occupying consecutive 
positions in linear order; a value can be transferred to or from an element 
of the file at any selected position. The position of an element is specified 
by its 
index, which is a number, greater than zero, of the implementation-defined 
integer type Count. The first element, if any, has index one; the index 
of the last element, if any, is called the 
current size; the current 
size is zero if there are no elements. The current size is a property 
of the external file.
 
4
An open direct file has a 
current 
index, which is the index that will be used by the next read or write 
operation. When a direct file is opened, the current index is set to 
one. The current index of a direct file is a property of a file object, 
not of an external file. 
 
Wording Changes from Ada 95
4.a/2
{
AI95-00283-01} 
Italicized “stream file” to clarify 
that this is another kind of file.  
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe