* [Ada.]Text_IO.Create
@ 1997-05-13 0:00 John McCabe
1997-05-14 0:00 ` [Ada.]Text_IO.Create Jeff Carter
1997-05-15 0:00 ` [Ada.]Text_IO.Create John McCabe
0 siblings, 2 replies; 4+ messages in thread
From: John McCabe @ 1997-05-13 0:00 UTC (permalink / raw)
I'd be grateful if anyone would let me know their thoughts, or correct
me on the following matter. I'd also appreciate any replies via email
to mccabe@mmsuk.co.uk.
I am currently trying to implement some very basic file handling on an
embedded VME PC with a floppy disk drive attached. I'm trying to make
it look similar to the Text_IO specification (I know you can get this
with some compilers, and from some third parties probably, but we
don't have it so we're doing it ourselves).
Anyway, I am currently trying to implement a Create function (like in
Text_IO), however it is not clear to me (either from the Ada 83 LRM or
the Ada 95 ARM) exactly what behaviour is expected if Create is called
for a file that already exists. It does state that it "Establishes a
new external file", however this seems a bit wooly.
I then had a look at the a-textio.ads/b and s-fileio.adb files to see
how this case was handled in GNAT, and noted that if GNAT is creating
an Out_File, it uses the open method "w" in a call to fopen which, if
the file already exists, will [probably] truncate it.
This would be the behaviour I personally would expect, and I wonder if
this is actually what is meant by "Establishes a new external file",
however I also wonder whether alternative behaviour such as raising
NAME_ERROR or USE_ERROR would be acceptable, or possibly even
appending to the existing file (but this sounds wrong).
Further, I find the concept of creating an In_File interesting. I
noted from s-fileio.adb that if a call to Create is made with the mode
In_File, the open method "w+" is passed to the fopen function (i.e.
append-ish). I'd appreciate the information if anyone knows whether
this is a typical implementation and whether there is some precedent
or advice anywhere on this matter. I did look to the Ada 95 Rationale
for information but found nothing of use on this subject.
Thanks in advance for any information.
Best Regards
John McCabe <john@assen.demon.co.uk>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Ada.]Text_IO.Create
1997-05-13 0:00 [Ada.]Text_IO.Create John McCabe
@ 1997-05-14 0:00 ` Jeff Carter
[not found] ` <dewar.863640175@merv>
1997-05-15 0:00 ` [Ada.]Text_IO.Create John McCabe
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Carter @ 1997-05-14 0:00 UTC (permalink / raw)
John McCabe wrote:
...
> Anyway, I am currently trying to implement a Create function (like in
> Text_IO), however it is not clear to me (either from the Ada 83 LRM or
> the Ada 95 ARM) exactly what behaviour is expected if Create is called
> for a file that already exists. It does state that it "Establishes a
> new external file", however this seems a bit wooly.
...
I think you'll find that this behavior is implementation defined. ALMOST
all versions I've used deleted the existing file and created a new,
empty file with the same name (or truncated the existing file to zero
bytes; I can't tell the difference :). Anyway, since you're creating an
implementation, you're free to decide what it does.
--
Jeff Carter PGP:1024/440FBE21
Auntie-spam reply to; try ( carter @ innocon . com )
"Now go away, or I shall taunt you a second time."
Monty Python & the Holy Grail
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Ada.]Text_IO.Create
[not found] ` <dewar.863640175@merv>
@ 1997-05-15 0:00 ` Larry Kilgallen
0 siblings, 0 replies; 4+ messages in thread
From: Larry Kilgallen @ 1997-05-15 0:00 UTC (permalink / raw)
In article <dewar.863640175@merv>, dewar@merv.cs.nyu.edu (Robert Dewar) writes:
> Jeff said
>
> <<I think you'll find that this behavior is implementation defined. ALMOST
> all versions I've used deleted the existing file and created a new,
> empty file with the same name (or truncated the existing file to zero
> bytes; I can't tell the difference :). Anyway, since you're creating an
> implementation, you're free to decide what it does.>
>
> No, I think you will find the behavior very consistent accross
> implementations (have a look at the chapter 14 tests in the ACVC!)
If those tests are the ones DEC Ada passed, then I guess the proper
behaviour is the one I always thought was proper...
...create a new file with the next higher version number !!!
Larry Kilgallen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Ada.]Text_IO.Create
1997-05-13 0:00 [Ada.]Text_IO.Create John McCabe
1997-05-14 0:00 ` [Ada.]Text_IO.Create Jeff Carter
@ 1997-05-15 0:00 ` John McCabe
1 sibling, 0 replies; 4+ messages in thread
From: John McCabe @ 1997-05-15 0:00 UTC (permalink / raw)
john@assen.demon.co.uk (John McCabe) wrote:
That's all very well, but...
What about this bit?
>Further, I find the concept of creating an In_File interesting. I
>noted from s-fileio.adb that if a call to Create is made with the mode
>In_File, the open method "w+" is passed to the fopen function (i.e.
>append-ish). I'd appreciate the information if anyone knows whether
>this is a typical implementation and whether there is some precedent
>or advice anywhere on this matter. I did look to the Ada 95 Rationale
>for information but found nothing of use on this subject.
Best Regards
John McCabe <john@assen.demon.co.uk>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1997-05-15 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-13 0:00 [Ada.]Text_IO.Create John McCabe
1997-05-14 0:00 ` [Ada.]Text_IO.Create Jeff Carter
[not found] ` <dewar.863640175@merv>
1997-05-15 0:00 ` [Ada.]Text_IO.Create Larry Kilgallen
1997-05-15 0:00 ` [Ada.]Text_IO.Create John McCabe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox