comp.lang.ada
 help / color / mirror / Atom feed
* Create and Append_File
@ 2019-06-06 20:45 Jeffrey R. Carter
  2019-06-06 21:24 ` Randy Brukardt
  0 siblings, 1 reply; 7+ messages in thread
From: Jeffrey R. Carter @ 2019-06-06 20:45 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Create and Append_File
  2019-06-06 20:45 Create and Append_File Jeffrey R. Carter
@ 2019-06-06 21:24 ` Randy Brukardt
  2019-06-07  8:01   ` Simon Wright
  2019-06-07 15:56   ` Jeffrey R. Carter
  0 siblings, 2 replies; 7+ messages in thread
From: Randy Brukardt @ 2019-06-06 21:24 UTC (permalink / raw)


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@spam.not.acm.org> wrote in message 
news:qdbu0n$cor$1@dont-email.me...
> 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 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Create and Append_File
  2019-06-06 21:24 ` Randy Brukardt
@ 2019-06-07  8:01   ` Simon Wright
  2019-06-07 15:59     ` Jeffrey R. Carter
  2019-11-27 21:40     ` Simon Wright
  2019-06-07 15:56   ` Jeffrey R. Carter
  1 sibling, 2 replies; 7+ messages in thread
From: Simon Wright @ 2019-06-07  8:01 UTC (permalink / raw)


"Randy Brukardt" <randy@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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Create and Append_File
  2019-06-06 21:24 ` Randy Brukardt
  2019-06-07  8:01   ` Simon Wright
@ 2019-06-07 15:56   ` Jeffrey R. Carter
  2019-06-08  5:00     ` Randy Brukardt
  1 sibling, 1 reply; 7+ messages in thread
From: Jeffrey R. Carter @ 2019-06-07 15:56 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Create and Append_File
  2019-06-07  8:01   ` Simon Wright
@ 2019-06-07 15:59     ` Jeffrey R. Carter
  2019-11-27 21:40     ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Jeffrey R. Carter @ 2019-06-07 15:59 UTC (permalink / raw)


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.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Create and Append_File
  2019-06-07 15:56   ` Jeffrey R. Carter
@ 2019-06-08  5:00     ` Randy Brukardt
  0 siblings, 0 replies; 7+ messages in thread
From: Randy Brukardt @ 2019-06-08  5:00 UTC (permalink / raw)


"Jeffrey R. Carter" <spam.jrcarter.not@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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Create and Append_File
  2019-06-07  8:01   ` Simon Wright
  2019-06-07 15:59     ` Jeffrey R. Carter
@ 2019-11-27 21:40     ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Wright @ 2019-11-27 21:40 UTC (permalink / raw)


On Friday, 7 June 2019 09:01:15 UTC+1, Simon Wright  wrote:
> "Randy Brukardt" <randy@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

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-27 21:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06 20:45 Create and Append_File Jeffrey R. Carter
2019-06-06 21:24 ` Randy Brukardt
2019-06-07  8:01   ` Simon Wright
2019-06-07 15:59     ` Jeffrey R. Carter
2019-11-27 21:40     ` Simon Wright
2019-06-07 15:56   ` Jeffrey R. Carter
2019-06-08  5:00     ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox