comp.lang.ada
 help / color / mirror / Atom feed
* What good are File_Access's?
@ 1998-07-17  0:00 dennison
  1998-07-17  0:00 ` Tucker Taft
  1998-07-18  0:00 ` Robert Dewar
  0 siblings, 2 replies; 6+ messages in thread
From: dennison @ 1998-07-17  0:00 UTC (permalink / raw)


It looks to me like the whole point of the File_Access type in Ada.Text_IO is
to allow Standard_Output and Current_Output (and the same functions for Input
and Error) to be compared in order to see if I/O has been redirected somehow.
However, when I compile and execute a DOS program using ObjectAda on NT,
Ada.Text_IO.Current_Output and Ada.Text_IO.Standard_Output are *not* equal. If
I do an Ada.Text_IO to either, it gets printed in my shell window.

So if I can't use the equality operations of File_Access to see where output
is going, what was the type put in there for? There's nothing else other than
the Standard* and Current* functions that give me one, and the only
operations allowed are equality comparison and assignment.

T.E.D.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

* Re: What good are File_Access's?
  1998-07-17  0:00 What good are File_Access's? dennison
@ 1998-07-17  0:00 ` Tucker Taft
  1998-07-18  0:00 ` Robert Dewar
  1 sibling, 0 replies; 6+ messages in thread
From: Tucker Taft @ 1998-07-17  0:00 UTC (permalink / raw)


dennison@telepath.com wrote:

: It looks to me like the whole point of the File_Access type in Ada.Text_IO is
: to allow Standard_Output and Current_Output (and the same functions for Input
: and Error) to be compared in order to see if I/O has been redirected somehow.

Interesting...  The real reason was so that you could save the value of
"current_output", change it to something else, and then set it back.
I don't believe we ever discussed the idea of whether the equality operator
should return something meaningful for two different File_Access values
which in some sense designate the "same" file.

: However, when I compile and execute a DOS program using ObjectAda on NT,
: Ada.Text_IO.Current_Output and Ada.Text_IO.Standard_Output are *not* equal. If
: I do an Ada.Text_IO to either, it gets printed in my shell window.

: So if I can't use the equality operations of File_Access to see where output
: is going, what was the type put in there for? There's nothing else other than
: the Standard* and Current* functions that give me one, and the only
: operations allowed are equality comparison and assignment.

: T.E.D.

: -----== Posted via Deja News, The Leader in Internet Discussion ==-----
: http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




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

* Re: What good are File_Access's?
  1998-07-17  0:00 What good are File_Access's? dennison
  1998-07-17  0:00 ` Tucker Taft
@ 1998-07-18  0:00 ` Robert Dewar
  1998-07-20  0:00   ` dennison
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Dewar @ 1998-07-18  0:00 UTC (permalink / raw)


T.E.D. said

>It looks to me like the whole point of the File_Access type in Ada.Text_IO is
>to allow Standard_Output and Current_Output (and the same functions for Input
>and Error) to be compared in order to see if I/O has been redirected somehow.
>However, when I compile and execute a DOS program using ObjectAda on NT,
>Ada.Text_IO.Current_Output and Ada.Text_IO.Standard_Output are *not* equal. If
>I do an Ada.Text_IO to either, it gets printed in my shell window.
>
>So if I can't use the equality operations of File_Access to see where output
>is going, what was the type put in there for? There's nothing else other than
>the Standard* and Current* functions that give me one, and the only
>operations allowed are equality comparison and assignment.

No, the point of this feature is to allow you to save and restore the
value of Current_Output. Ted's theory is interesting, but there is nothing
in the RM to suggest that this equality test is expected to work, let alone
required to work!

Indeed it is easy to imagine that two values designating the same file
would very likely not be equal.





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

* Re: What good are File_Access's?
  1998-07-20  0:00   ` dennison
@ 1998-07-20  0:00     ` Robert Dewar
  1998-07-20  0:00       ` dennison
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Dewar @ 1998-07-20  0:00 UTC (permalink / raw)


<<Ahhhh. That's the answer I was looking for.
I didn't consider that as a possibility because that method of saving off the
Current_Output won't work in a multi-tasking environment. You'd need some kind
of "atomic" save-and-change operation. Since that is %90 of the Ada programs I
have ever worked on, that doesn't make it too useful.
>>


Well it simply needs protecting in a multi-tasking environment. You generalloy
need to have some control over Text_IO anyway (for example, you certainly
cannot do Put_Line operations on standard output at the same time from
two separate tasks without proper synchronization.





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

* Re: What good are File_Access's?
  1998-07-20  0:00     ` Robert Dewar
@ 1998-07-20  0:00       ` dennison
  0 siblings, 0 replies; 6+ messages in thread
From: dennison @ 1998-07-20  0:00 UTC (permalink / raw)


In article <dewar.900954709@merv>,
  dewar@merv.cs.nyu.edu (Robert Dewar) wrote:
> <<Ahhhh. That's the answer I was looking for.
> I didn't consider that as a possibility because that method of saving off the
> Current_Output won't work in a multi-tasking environment. You'd need some kind
> of "atomic" save-and-change operation. Since that is %90 of the Ada programs I
> have ever worked on, that doesn't make it too useful.
> >>
>
> Well it simply needs protecting in a multi-tasking environment. You generalloy
> need to have some control over Text_IO anyway (for example, you certainly
> cannot do Put_Line operations on standard output at the same time from
> two separate tasks without proper synchronization.

True. But having to manage task access to the same *file* is a little
different than having to manage task access to the global default for all of
Text_IO. The former can be accomplished by the simple rule "only task X gets
to access file Y" (or by more complicated means). The latter ... hmmm ... it
would be grisly.

You'd really need a default for each task. I guess you could reimplement all
of Text_IO as a task, using Caller ID's to index into an array of defaults.
Yuk.

Yeah, its basicly useless.

T.E.D.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

* Re: What good are File_Access's?
  1998-07-18  0:00 ` Robert Dewar
@ 1998-07-20  0:00   ` dennison
  1998-07-20  0:00     ` Robert Dewar
  0 siblings, 1 reply; 6+ messages in thread
From: dennison @ 1998-07-20  0:00 UTC (permalink / raw)


In article <dewar.900786542@merv>,
  dewar@merv.cs.nyu.edu (Robert Dewar) wrote:
> T.E.D. said
>
> >It looks to me like the whole point of the File_Access type in Ada.Text_IO is
> >to allow Standard_Output and Current_Output (and the same functions for Input
> >and Error) to be compared in order to see if I/O has been redirected somehow.

> No, the point of this feature is to allow you to save and restore the
> value of Current_Output. Ted's theory is interesting, but there is nothing
> in the RM to suggest that this equality test is expected to work, let alone
> required to work!

Ahhhh. That's the answer I was looking for.
I didn't consider that as a possibility because that method of saving off the
Current_Output won't work in a multi-tasking environment. You'd need some kind
of "atomic" save-and-change operation. Since that is %90 of the Ada programs I
have ever worked on, that doesn't make it too useful.

It does look like it might have some application for streams too...

> Indeed it is easy to imagine that two values designating the same file
> would very likely not be equal.
Apparently not. (sigh) Oh well. On to Plan B.

T.E.D.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

end of thread, other threads:[~1998-07-20  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-17  0:00 What good are File_Access's? dennison
1998-07-17  0:00 ` Tucker Taft
1998-07-18  0:00 ` Robert Dewar
1998-07-20  0:00   ` dennison
1998-07-20  0:00     ` Robert Dewar
1998-07-20  0:00       ` dennison

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