comp.lang.ada
 help / color / mirror / Atom feed
* SEQUENTIA_IO and stdin/stdout
@ 2003-10-14 12:44 Lo Shu
  2003-10-14 14:29 ` SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output) Larry Kilgallen
  0 siblings, 1 reply; 9+ messages in thread
From: Lo Shu @ 2003-10-14 12:44 UTC (permalink / raw)


Hi community,

I came from C world and brought the question: how I can open stdin or
stdout as a SEQUENTIAL file?

Thank you.



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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-14 12:44 SEQUENTIA_IO and stdin/stdout Lo Shu
@ 2003-10-14 14:29 ` Larry Kilgallen
  2003-10-14 16:45   ` Marius Amado Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Larry Kilgallen @ 2003-10-14 14:29 UTC (permalink / raw)


In article <55cccaab.0310140444.4ac20d7f@posting.google.com>, iin@rgdata.ukrtel.net (Lo Shu) writes:

> I came from C world and brought the question: how I can open stdin or
> stdout as a SEQUENTIAL file?

Parameterless function Text_IO.Standard_Input returns a value of File_Type.

Function Text_IO.Name takes a value of File_Type as a parameter and returns
the name of the corresponding file.



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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-14 14:29 ` SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output) Larry Kilgallen
@ 2003-10-14 16:45   ` Marius Amado Alves
  2003-10-14 20:36     ` Robert I. Eachus
  2003-10-14 23:11     ` Larry Kilgallen
  0 siblings, 2 replies; 9+ messages in thread
From: Marius Amado Alves @ 2003-10-14 16:45 UTC (permalink / raw)
  To: comp.lang.ada

On Tue, 2003-10-14 at 14:29, Larry Kilgallen wrote:
> > I came from C world and brought the question: how I can open stdin or
> > stdout as a SEQUENTIAL file?
> 
> Parameterless function Text_IO.Standard_Input returns a value of File_Type.
> 
> Function Text_IO.Name takes a value of File_Type as a parameter and returns
> the name of the corresponding file.

Are you suggesting the trick of finding out the name of Standard_Output
(say) and then open a sequential file with that name? Sounds clever, but
unfortunately it doesn't work. See my previous reply (actually a
forward) for a 'proper' solution to this problem.




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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-14 16:45   ` Marius Amado Alves
@ 2003-10-14 20:36     ` Robert I. Eachus
  2003-10-14 23:11     ` Larry Kilgallen
  1 sibling, 0 replies; 9+ messages in thread
From: Robert I. Eachus @ 2003-10-14 20:36 UTC (permalink / raw)


Marius Amado Alves wrote:

> Are you suggesting the trick of finding out the name of Standard_Output
> (say) and then open a sequential file with that name? Sounds clever, but
> unfortunately it doesn't work. See my previous reply (actually a
> forward) for a 'proper' solution to this problem.

Technically, it may or may not work.  For example, Standard_Output could 
be assigned to a file on the command line when running the program. Then 
  Standard_Output could be closed, and the file reopened by name in 
Sequential_IO.  But agreed, using Streams is the way to go.

-- 
                                                     Robert I. Eachus

"Quality is the Buddha. Quality is scientific reality. Quality is the 
goal of Art. It remains to work these concepts into a practical, 
down-to-earth context, and for this there is nothing more practical or 
down-to-earth than what I have been talking about all along...the repair 
of an old motorcycle."  -- from Zen and the Art of Motorcycle 
Maintenance by Robert Pirsig




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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-14 23:11     ` Larry Kilgallen
@ 2003-10-14 23:11       ` Marius Amado Alves
  2003-10-15  4:32         ` Larry Kilgallen
  0 siblings, 1 reply; 9+ messages in thread
From: Marius Amado Alves @ 2003-10-14 23:11 UTC (permalink / raw)
  To: comp.lang.ada

On Tue, 2003-10-14 at 23:11, Larry Kilgallen wrote:
> > Are you suggesting the trick of finding out the name of Standard_Output
> > (say) and then open a sequential file with that name? Sounds clever, but
> > unfortunately it doesn't work.
> 
> Why not ?   What error do you get ?

I think the ARM does not guarantee it.
With GNAT no output is produced.
I suppose another compiler could work as desired.




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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-14 16:45   ` Marius Amado Alves
  2003-10-14 20:36     ` Robert I. Eachus
@ 2003-10-14 23:11     ` Larry Kilgallen
  2003-10-14 23:11       ` Marius Amado Alves
  1 sibling, 1 reply; 9+ messages in thread
From: Larry Kilgallen @ 2003-10-14 23:11 UTC (permalink / raw)


In article <mailman.80.1066149976.25614.comp.lang.ada@ada-france.org>, Marius Amado Alves <amado.alves@netcabo.pt> writes:
> On Tue, 2003-10-14 at 14:29, Larry Kilgallen wrote:
>> > I came from C world and brought the question: how I can open stdin or
>> > stdout as a SEQUENTIAL file?
>> 
>> Parameterless function Text_IO.Standard_Input returns a value of File_Type.
>> 
>> Function Text_IO.Name takes a value of File_Type as a parameter and returns
>> the name of the corresponding file.
> 
> Are you suggesting the trick of finding out the name of Standard_Output
> (say) and then open a sequential file with that name? Sounds clever, but
> unfortunately it doesn't work.

Why not ?   What error do you get ?



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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-14 23:11       ` Marius Amado Alves
@ 2003-10-15  4:32         ` Larry Kilgallen
  2003-10-15 17:23           ` Marius Amado Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Larry Kilgallen @ 2003-10-15  4:32 UTC (permalink / raw)


In article <mailman.85.1066173102.25614.comp.lang.ada@ada-france.org>, Marius Amado Alves <amado.alves@netcabo.pt> writes:
> On Tue, 2003-10-14 at 23:11, Larry Kilgallen wrote:
>> > Are you suggesting the trick of finding out the name of Standard_Output
>> > (say) and then open a sequential file with that name? Sounds clever, but
>> > unfortunately it doesn't work.
>> 
>> Why not ?   What error do you get ?
> 
> I think the ARM does not guarantee it.

Which of the three steps is not guaranteed ?

	Finding the value of File_Type

	Finding the name of the corresponding file

	Opening the file

If it is the last, I would expect a failure to open would signal an exception.

> With GNAT no output is produced.
> I suppose another compiler could work as desired.



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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-15  4:32         ` Larry Kilgallen
@ 2003-10-15 17:23           ` Marius Amado Alves
  2003-10-17 13:41             ` Frank J. Lhota
  0 siblings, 1 reply; 9+ messages in thread
From: Marius Amado Alves @ 2003-10-15 17:23 UTC (permalink / raw)
  To: comp.lang.ada

> Which of the three steps is not guaranteed ?
> 
> 	Finding the value of File_Type
> 	Finding the name of the corresponding file
> 	Opening the file
> 
> If it is the last, I would expect a failure to open would signal an exception.

I would to. But GNAT does not complaint. At least with a sequential file
of characters. It simply does not output. Maybe it's because I'm not
closing Standard_Output prior to opening it as a sequential file. But I
wouldn't know how to do that. Procedure Close requires a variable, and
you cannot set a file type variable to Standard_Output (because
File_Type is limited).

I agree some kind of clarification on this issue is desirable. Maybe it
has been done already. Or a binding interpretation. Someone should check
it out ;-) Note Robert Eachus already said "it may or may not work".
Maybe he's willing to elaborate ;-)

Personally I don't feel comfortable with two things:

1. The (external) name of a standard channel. Even in C this does not
exist. GNAT says "*stdout", "*stdin". Note the asterisk. This reeks of implementation dependency. I
seem to remember MS-DOS having "CON" for this. I think the ARM is silent
on this anyway.

2. Crossing information between Text_IO and (an instance of)
Sequential_IO. Even if this information is just the name of the external
file.

In sum: there is doubtful solution (and erroneous with GNAT, or so it
seems), and there is an alternate, legal solution. The choice should be
clear.

As I indicated before, I suspect Ada has a weak point here. Namely
binding the standard channels exclusively to Text_IO. Surely the
standard channel concept is less dependent of file format than that.





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

* Re: SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output)
  2003-10-15 17:23           ` Marius Amado Alves
@ 2003-10-17 13:41             ` Frank J. Lhota
  0 siblings, 0 replies; 9+ messages in thread
From: Frank J. Lhota @ 2003-10-17 13:41 UTC (permalink / raw)


"Marius Amado Alves" <amado.alves@netcabo.pt> wrote in message
news:mailman.95.1066291541.25614.comp.lang.ada@ada-france.org...
> As I indicated before, I suspect Ada has a weak point here. Namely
> binding the standard channels exclusively to Text_IO. Surely the
> standard channel concept is less dependent of file format than that.

I know of no language that has a portable method for accessing the standard
channels (standard input, standard output, and standard error) in any
fashion other than as a text file.





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

end of thread, other threads:[~2003-10-17 13:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 12:44 SEQUENTIA_IO and stdin/stdout Lo Shu
2003-10-14 14:29 ` SEQUENTIA_IO and stdin/stdout (Standard_Input, Standard_Output) Larry Kilgallen
2003-10-14 16:45   ` Marius Amado Alves
2003-10-14 20:36     ` Robert I. Eachus
2003-10-14 23:11     ` Larry Kilgallen
2003-10-14 23:11       ` Marius Amado Alves
2003-10-15  4:32         ` Larry Kilgallen
2003-10-15 17:23           ` Marius Amado Alves
2003-10-17 13:41             ` Frank J. Lhota

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