experchange > ada

Jeffrey R. Carter (06-06-19, 10:45 PM)
You can call Create with mode Append_File. I'm trying to figure out what that's
supposed to do (as opposed to what compilers do). I've read ARM A.7, A.8.2, and
A.10.2, and am still not sure.

It seems there are 2 likely interpretations:

1. Create creates a file, so this is the same as using mode Out_File
2. Since mode Append_File was given, it means to open the file in append mode if
it exists, or create it as for mode Out_File if it doesn't

If 1., then why allow Append_File for Create? A subtype excluding it could be
defined for Create.

Of course, you can also Create a file with mode In_File, which I presume means
to create an empty file and open it for reading, which doesn't seem very useful,
so maybe I shouldn't expect these to make sense.
Randy Brukardt (06-06-19, 11:24 PM)
I believe it means the same as Out_File. Other requirements in RM (not very
clear ones, I'm afraid) require the file opened by Create to be empty,
whether or not the file previously existed. So, if Create allows
(re)creating an existing file (it doesn't have to, it could raise
Use_Error), that file will be empty. In that case, Out_File and Append_File
are the same.

As you note, Create (In_File) is already nonsense, so Create (Append_File)
might as well be nonsense as well (it's *less* nonsense in any case, since a
modeless Reset preserves the mode, and the file wouldn't necessarily be
empty at that point).

Randy.

"Jeffrey R. Carter" <spam.jrcarter.not> wrote in message
news:cor1
[..]
Simon Wright (06-07-19, 10:01 AM)
"Randy Brukardt" <randy> writes:

> As you note, Create (In_File) is already nonsense, so Create
> (Append_File) might as well be nonsense as well (it's *less* nonsense
> in any case, since a modeless Reset preserves the mode, and the file
> wouldn't necessarily be empty at that point).


I guess I should add this to my StackOverflow answer which may have been
the trigger for this question. I have No Idea why I thought it sensible
to Create the file in Append_File mode.

Jeffrey R. Carter (06-07-19, 05:56 PM)
On 6/6/19 11:24 PM, Randy Brukardt wrote:
> I believe it means the same as Out_File. Other requirements in RM (not very
> clear ones, I'm afraid) require the file opened by Create to be empty,
> whether or not the file previously existed. So, if Create allows
> (re)creating an existing file (it doesn't have to, it could raise
> Use_Error), that file will be empty. In that case, Out_File and Append_File
> are the same.


Thanks for the clarification. Which parts of the standard state that requirement
unclearly?
Jeffrey R. Carter (06-07-19, 05:59 PM)
On 6/7/19 10:01 AM, Simon Wright wrote:
> I guess I should add this to my StackOverflow answer which may have been
> the trigger for this question. I have No Idea why I thought it sensible
> to Create the file in Append_File mode.


Yes, I saw Create with Append_File and wondered what that should do. It seemed
reasonable that it would open the file in append mode if it existed, and create
it in output mode otherwise, but that's not what GNAT does, so here we are.
Randy Brukardt (06-08-19, 07:00 AM)
"Jeffrey R. Carter" <spam.jrcarter.not> wrote in message
news:s9n1
> On 6/6/19 11:24 PM, Randy Brukardt wrote:
> Thanks for the clarification. Which parts of the standard state that
> requirement unclearly?


I couldn't find them quickly, which I way I wrote the above that
unsatisfying way. And if it was too hard yesterday, it will remain that way
today. Sorry.

Randy.
Simon Wright (11-27-19, 11:40 PM)
On Friday, 7 June 2019 09:01:15 UTC+1, Simon Wright wrote:
> "Randy Brukardt" <randy> writes:
> I guess I should add this to my StackOverflow answer which may have been
> the trigger for this question. I have No Idea why I thought it sensible
> to Create the file in Append_File mode.
>


I see that I did update that answer, with
Similar Threads