Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create and Append_File

145 views
Skip to first unread message

Jeffrey R. Carter

unread,
Jun 6, 2019, 4:45:13 PM6/6/19
to
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.

--
Jeff Carter
"He nevere yet no vileynye ne sayde
In al his lyf unto no maner wight."
Canterbury Tales
156

Randy Brukardt

unread,
Jun 6, 2019, 5:24:53 PM6/6/19
to
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.jrc...@spam.not.acm.org> wrote in message
news:qdbu0n$cor$1...@dont-email.me...

Simon Wright

unread,
Jun 7, 2019, 4:01:15 AM6/7/19
to
"Randy Brukardt" <ra...@rrsoftware.com> 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.

https://stackoverflow.com/a/56404909/40851

Jeffrey R. Carter

unread,
Jun 7, 2019, 11:56:56 AM6/7/19
to
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?

--
Jeff Carter
"You couldn't catch clap in a brothel, silly English K...niggets."
Monty Python & the Holy Grail
19

Jeffrey R. Carter

unread,
Jun 7, 2019, 11:59:41 AM6/7/19
to
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

unread,
Jun 8, 2019, 1:00:13 AM6/8/19
to
"Jeffrey R. Carter" <spam.jrc...@spam.not.acm.org> wrote in message
news:qde1g7$s9n$1...@dont-email.me...
> 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?

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

unread,
Nov 27, 2019, 4:40:40 PM11/27/19
to
I see that I did update that answer, with

>At first glance, you might wonder what the point of opening a file that must have been empty in append mode is. Normally, of course, it might as well have been opened in standard out mode; the only difference would be if for some reason you had to use the modeless [`Reset`](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-A-10-1.html#p11). In that case, if the file was created in append mode it would remain in append mode, so any previous updates wouldn’t be lost.
0 new messages