Version 1.1 of acs/ac-00264.txt

Unformatted version of acs/ac-00264.txt version 1.1
Other versions for file acs/ac-00264.txt

!standard A.8.2(3/2)          14-10-09 AC95-00264/00
!standard A.8.2(7)
!class confirmation 14-10-09
!status received no action 14-10-09
!status received 14-10-01
!subject Universal fixed-fixed operation and universal real result
!summary
!appendix

!topic        Ada.Direct_IO: Index after Create resp. Open
!reference  Ada 2012 RM A.8.2(3/2,7)
!from         Christoph Grein  2014-09-25
!discussion

Neither Create nor Open specify the value of Index, which will be used for Read
or Write, see A.8.5(3,6,11), for the very first access with the procedures
without the Positive_Count parameter (must be 1, of course).

Should this oversight be corrected?

***************************************************************

From: Dmitry A. Kazakov
Sent: Wednesday, October  1, 2014  3:00 PM

> !topic        Ada.Direct_IO: Index after Create resp. Open
> !reference  Ada 2012 RM A.8.2(3/2,7)
> !from         Christoph Grein  2014-09-25
> !discussion
> Neither Create nor Open specify the value of Index, which will be used
> for Read or Write, see A.8.5(3,6,11), for the very first access with
> the procedures without the Positive_Count parameter (must be 1, of course).

In the case of Out_File it probably should be the last index + 1. For other
modes it should be 1.

> Should this oversight be corrected?

If something gets changed then I have two further issues:

1. Missing procedure Flush.

2. It not specified if Write sets the physical file end when the file is written
   beyond its current end. There are two possibilities.

2.1. If Write is not required to set the file end, then Flush must be added to
     do this without closing the file.

2.2. If Write sets the file end then Flush might be less necessary yet desired.
     This must happen at least in the Inout_File mode in order to make Read
     working.

***************************************************************

From: Egil Harald Hoevik
Sent: Thursday, October  2, 2014  1:33 AM

> Neither Create nor Open specify the value of Index, which will be used
> for Read or Write, see A.8.5(3,6,11), for the very first access with
> the procedures without the Positive_Count parameter (must be 1, of course).
>
> Should this oversight be corrected?
>

I believe that's covered by A.8(3-4)

***************************************************************

From: Christoph Grein
Sent: Thursday, October  2, 2014  4:50 AM

As a further minor side note, the value with the index Positive_Count'Last can
never be (reliably) written nor read since Constraint_Error will be raised upon
index increase.

***************************************************************

From: Randy Brukardt
Sent: Thursday, October  2, 2014  1:51 PM

> I believe that's covered by A.8(3-4)

Thanks!

A.8(4) says "When a direct file is opened, the current index is set to one."
Hardly could be any clearer than that. Perhaps it isn't in the best possible
place, but it certainly is stated normatively.

***************************************************************

From: Randy Brukardt
Sent: Thursday, October  2, 2014  2:12 PM

...
> 1. Missing procedure Flush.

Text_IO and Stream_IO have Flush. Sequential_IO and Direct_IO do not. I believe
the presumption is that neither of these other packages will use any buffering,
at least WRT to the underlying target OS. So Flush would have no effect (the
definition in Ada is about flushing *internal* buffers, it doesn't say anything
about the effect on the target OS). [Aside: I believe most implementations of
Flush try to call something in the target OS, if there is such an operation, but
that is clearly not required by the Standard.]

There might be a consistency argument for the other packages, but that clearly
was considered and rejected when Flush was added in Ada 95. Perhaps someone
knows why that was?

> 2. It not specified if Write sets the physical file end when the file
> is written beyond its current end. There are two possibilities.
>
> 2.1. If Write is not required to set the file end, then Flush must be
> added to do this without closing the file.

How could this work? Direct_IO does no buffering, so Write doesn't return until
the data has been written to the OS. So if the file end isn't changed, there
would be data past the file end, which is obvious nonsense. In any case, any
buffering that the target OS does has to be transparent to the Ada application.
And most certainly Ada does not expect that having multiple processes writing
the same file simultaneously would work (it would be invalid use of a shared
variable, just as in a single Ada program).

> 2.2. If Write sets the file end then Flush might be less necessary yet
> desired. This must happen at least in the Inout_File mode in order to
> make Read working.

This seems to be the only sensible semantics. There isn't supposed to be any
buffering at the Ada level, so any other semantics violates the Dewar rule.

***************************************************************

Questions? Ask the ACAA Technical Agent