* Ada.Streams.Stream_IO.File_Type @ 2003-07-15 20:13 tmoran 2003-07-17 15:10 ` Ada.Streams.Stream_IO.File_Type Craig Carey ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: tmoran @ 2003-07-15 20:13 UTC (permalink / raw) Why is this not a descendant of Ada.Finalization.Limited_Controlled? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-15 20:13 Ada.Streams.Stream_IO.File_Type tmoran @ 2003-07-17 15:10 ` Craig Carey 2003-07-17 16:42 ` Ada.Streams.Stream_IO.File_Type Nick Roberts 2003-07-17 16:01 ` Ada.Streams.Stream_IO.File_Type Nick Roberts 2003-07-18 7:46 ` Ada.Streams.Stream_IO.File_Type Dmitry A. Kazakov 2 siblings, 1 reply; 11+ messages in thread From: Craig Carey @ 2003-07-17 15:10 UTC (permalink / raw) On Tue, 15 Jul 2003 20:13:37 GMT, tmoran@acm.org wrote: --------------------------- >Why is this [Ada.Streams.Stream_IO.File_Type] not a descendant of > Ada.Finalization.Limited_Controlled? --------------------------- That would be done to allow no call to Close(). Close might raise errors. GNAT's already code has the doubly linked list (in GNAT-'only' package System.File_Control_Block). --- From another thread (mis)titled "Re: Terminating a task" It was on the 2nd computer language shootout contest: http://dada.perl.it/shootout/ (wc example: counting words in binary) --------------------------- On Tue, 15 Jul 2003 13:30:33 -0500, "David C. Hoos" >The package Ada.TextIO.Text_Streams allows one to obtain the stream > object corresponding to the standard input -- i.e.: > >Standard_Input_Stream : Ada.Text_IO.Text_Streams.Stream_Access = > Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Input); --------------------------- This comment is not on Text_Streams: --------------------------- From: "Randy Brukardt" <randy@rrsoftware.com> Newsgroups: comp.lang.ada Subject: Re: Fill string with multiple lines from standard_input Date: Fri, 16 Aug 2002 21:26:29 -0500 ... Keep in mind that Stream_IO was virtually untested by the ACATS until recently, and even now the standard has serious problems which can make the use of Stream_IO non-portable (since compilers pretty much all do the wrong thing). So even an implementation which passes the ACATS tests may still have problems in some cases (having to do with writing, [...] --------------------------- It is a problem with the design rather than the testing. ACT doesn't like the design. A fix would be to add this next line to Ada.Streams.Stream_IO: function Standard_Input return File_Type; Anyone know why it is not in there already?. Portable Ada programs handling piping or CGI I/O may need that unless using C (etc.). I looked for an AI or comment at Ada-Comment, hinting that a fix is desired or intended, but found nothing. Using C's setmode() and read() seems to be a good solution. -- Currently GNAT 3.15's Text_IO.Text_Streams feature stops reading, on encountering a ASCII.SUB character (= character 10#26#). Presumably they don't like the RM's design. Demo code: % cat data | tr \\032-\\032 " " | wc ---------------------------------- type Tio is Ada.Text_IO; In_Stream : Tio.Text_Streams.Stream_Access; Out_Stream : Tio.Text_Streams.Stream_Access; Input_Chars : Ada.Streams.Stream_Element_Array (1 .. 1024); Last : Ada.Streams.Stream_Element_Offset; ... -- Now use the "do a type conversions on a pointer" package: In_Stream := Tio.Text_Streams.Stream (Tio.Current_Input); Out_Stream := Tio.Text_Streams.Stream (Tio.Current_Output); -- Now use the text package to handle binary I/O: loop Ada.Streams.Read (In_Stream.all, Input_Chars, Last); exit when Last = 0; -- Quit on the first ASCII.SUB character Ada.Streams.Write (Out_Stream.all, Input_Chars (1 .. Last)); end loop; ---------------------------------- AARM A.12.2: Package Text_IO.Text_Streams: http://www.adaic.org/standards/95aarm/html/AA-A-12-2.html AARM 13.13.1: Package Streams: http://www.adaic.org/standards/95aarm/html/AA-13-13-1.html AARM A.12.1: Package Streams.Stream_IO: http://www.adaic.org/standards/95aarm/html/AA-A-12-1.html ______ - Craig Carey How to Cross-Compiled in FreeBSD to/for a x86 Linux target: http://www.ijs.co.nz/code/ada95-freebsd-to-linux-cross-compiler.txt ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-17 15:10 ` Ada.Streams.Stream_IO.File_Type Craig Carey @ 2003-07-17 16:42 ` Nick Roberts 2003-07-18 17:34 ` Ada.Streams.Stream_IO.File_Type Matthew Heaney 0 siblings, 1 reply; 11+ messages in thread From: Nick Roberts @ 2003-07-17 16:42 UTC (permalink / raw) "Craig Carey" <research@ijs.co.nz> wrote in message news:mt7chvs7heoihdv7a3a6psh5h8v1b46i2i@4ax.com... > On Tue, 15 Jul 2003 13:30:33 -0500, "David C. Hoos" > > The package Ada.TextIO.Text_Streams allows one > > to obtain the stream object corresponding to the > > standard input -- i.e.: > > > > Standard_Input_Stream : > > Ada.Text_IO.Text_Streams.Stream_Access := > > Ada.Text_IO.Text_Streams.Stream > > (Ada.Text_IO.Standard_Input); > > This comment is not on Text_Streams: > ... > A fix would be to add this next line to Ada.Streams.Stream_IO: > > function Standard_Input return File_Type; > > Anyone know why it is not in there already? Yes! Because you can use the technique given by David Hoos. > Portable Ada programs handling piping or CGI I/O may > need that unless using C (etc.). If an Ada program which is a client of the Common Gateway Interface (CGI) -- used by various web (HTTP) server programs to allow 'client' programs to dyamically generate web pages -- implements the interface by directly interacting with its 'standard input' and 'standard output' (in the Unix sense), it must be considered essentially non-portable. Such a program may be portable among Unix-based (maybe POSIX-based) environments, but generally not otherwise. In this case, the Ada program might just as well import the appropriate C functions to read or write bytes directly; I would suggest that in most cases interaction is all text-based anyway, and it would be easier and better to use Ada.Text_IO (and if the Ada implementation isn't able to handle line termination correctly, I would say that's a major problem with the implementation). For true portability, an Ada program which is intended to be used as a CGI client should put everything specific to interfacing with the environment into a package (named 'CGI' perhaps ;-) and I'm fairly sure at least one such package is available. To port the program to a (significantly different) environment, this package (only) needs to be reimplemented. This would provide further advantageous isolation (such as from changes to the HTTP header that a CGI client program should output). > ... > Currently GNAT 3.15's Text_IO.Text_Streams feature > stops reading, on encountering a ASCII.SUB character > (= character 10#26#). That's just a problem with GNAT, isn't it? > Presumably they don't like the RM's design. Presumably it's a simple bug in GNAT 3.15. It's quite reasonable (in my 'humble' opinion :-) for text-oriented I/O (except Look_Ahead and Get_Immediate) to stop on a SUB, but not stream-oriented I/O. The RM permits this; I think it would often be handy for Ada implementations to provide options with regard to line, page, and file termination. -- Nick Roberts Jabber: debater@charente.de [ICQ: 159718630] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-17 16:42 ` Ada.Streams.Stream_IO.File_Type Nick Roberts @ 2003-07-18 17:34 ` Matthew Heaney 2003-07-18 18:25 ` Ada.Streams.Stream_IO.File_Type David C. Hoos 0 siblings, 1 reply; 11+ messages in thread From: Matthew Heaney @ 2003-07-18 17:34 UTC (permalink / raw) "Nick Roberts" <nickroberts@blueyonder.co.uk> wrote in message news:<bf6jhs$b9l6h$1@ID-25716.news.uni-berlin.de>... > > > Anyone know why it is not in there already? > > Yes! Because you can use the technique given by David Hoos. To which technique are you referring? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-18 17:34 ` Ada.Streams.Stream_IO.File_Type Matthew Heaney @ 2003-07-18 18:25 ` David C. Hoos 0 siblings, 0 replies; 11+ messages in thread From: David C. Hoos @ 2003-07-18 18:25 UTC (permalink / raw) To: comp.lang.ada ----- Original Message ----- From: "Matthew Heaney" <mheaney@on2.com> Newsgroups: comp.lang.ada To: <comp.lang.ada@ada.eu.org> Sent: Friday, July 18, 2003 12:34 PM Subject: Re: Ada.Streams.Stream_IO.File_Type > "Nick Roberts" <nickroberts@blueyonder.co.uk> wrote in message news:<bf6jhs$b9l6h$1@ID-25716.news.uni-berlin.de>... > > > > > Anyone know why it is not in there already? > > > > Yes! Because you can use the technique given by David Hoos. > > To which technique are you referring? He's probable referring to my message of July 15 in the thread "Terminating a Task." > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-15 20:13 Ada.Streams.Stream_IO.File_Type tmoran 2003-07-17 15:10 ` Ada.Streams.Stream_IO.File_Type Craig Carey @ 2003-07-17 16:01 ` Nick Roberts 2003-07-20 11:27 ` Ada.Streams.Stream_IO.File_Type Mário Amado Alves 2003-07-18 7:46 ` Ada.Streams.Stream_IO.File_Type Dmitry A. Kazakov 2 siblings, 1 reply; 11+ messages in thread From: Nick Roberts @ 2003-07-17 16:01 UTC (permalink / raw) <tmoran@acm.org> wrote in message news:RfZQa.71833$N7.8631@sccrnsc03... [of the type Ada.Streams.Stream_IO.File_Type] > Why is this not a descendant of > Ada.Finalization.Limited_Controlled? The visible declaration in the package Ada.Streams.Stream_IO is: type File_Type is limited private; This means that the type is not visibly a descendant of Limited_Controlled, but it could be implemented by putting: type File_Type is new Ada.Finalization.Limited_Controlled with private; in the private part of package Ada.Streams.Stream_IO. I'm not quite sure if such an implementation would be criticised on the grounds that objects of File_Type could not then be declared other than at library level. -- Nick Roberts Jabber: debater@charente.de [ICQ: 159718630] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-17 16:01 ` Ada.Streams.Stream_IO.File_Type Nick Roberts @ 2003-07-20 11:27 ` Mário Amado Alves 2003-07-20 14:25 ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus 0 siblings, 1 reply; 11+ messages in thread From: Mário Amado Alves @ 2003-07-20 11:27 UTC (permalink / raw) > ... > but it could be implemented by putting: > > type File_Type is new Ada.Finalization.Limited_Controlled with private; > > in the private part of package Ada.Streams.Stream_IO. I'm not quite sure if > such an implementation would be criticised on the grounds that objects of > File_Type could not then be declared other than at library level. Indeed it would be criticized by the many of us that find this Ada feature annoying. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-20 11:27 ` Ada.Streams.Stream_IO.File_Type Mário Amado Alves @ 2003-07-20 14:25 ` Robert I. Eachus 2003-07-21 4:03 ` Ada.Streams.Stream_IO.File_Type Nick Roberts 0 siblings, 1 reply; 11+ messages in thread From: Robert I. Eachus @ 2003-07-20 14:25 UTC (permalink / raw) M�rio Amado Alves wrote: >>... >>but it could be implemented by putting: >> >> type File_Type is new Ada.Finalization.Limited_Controlled with private; >> >>in the private part of package Ada.Streams.Stream_IO. I'm not quite sure if >>such an implementation would be criticised on the grounds that objects of >>File_Type could not then be declared other than at library level. > Indeed it would be criticized by the many of us that find this Ada feature annoying. So annoying that if there was such a requirement, I am sure that the ARG would immediately eliminate it! I think that Nick Roberts was thinking of the rule that prevents creating a TYPE derived from Ada.Finalization.Limited_Controlled other than at the library level from having a record extension RM 3.9.1(3) and the note at RM 3.9.1(7). I would like to loosen that up some in Ada 0Y to allow derived types of the form: type New_T is new tagged T; in some nested contexts. But it is probably not a high priority extension. (Note that the declaration above is not currently syntactically legal.) If it were added, though, the key would be insuring that there was no distributed overhead. That's the hard part. -- Robert I. Eachus �In an ally, considerations of house, clan, planet, race are insignificant beside two prime questions, which are: 1. Can he shoot? 2. Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and Steve Miller. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-20 14:25 ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus @ 2003-07-21 4:03 ` Nick Roberts 2003-07-21 9:47 ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus 0 siblings, 1 reply; 11+ messages in thread From: Nick Roberts @ 2003-07-21 4:03 UTC (permalink / raw) "Robert I. Eachus" <rieachus@attbi.com> wrote in message news:3F1AA639.5070200@attbi.com... > I think that Nick Roberts was thinking of the rule that > prevents creating a TYPE derived from Ada.Finalization > .Limited_Controlled other than at the library level from > having a record extension RM 3.9.1(3) and the note at > RM 3.9.1(7). I was. Sorry. -- Nick Roberts ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-21 4:03 ` Ada.Streams.Stream_IO.File_Type Nick Roberts @ 2003-07-21 9:47 ` Robert I. Eachus 0 siblings, 0 replies; 11+ messages in thread From: Robert I. Eachus @ 2003-07-21 9:47 UTC (permalink / raw) Nick Roberts wrote: > I was. Sorry. No, problem, I knew what you meant. But someone agreed with your post, so I responded to make sure we didn't get snarked: "Just the place for a Snark!" the Bellman cried, As he landed his crew with care; Supporting each man on the top of the tide By a finger entwined in his hair. "Just the place for a Snark! I have said it twice: That alone should encourage the crew. Just the place for a Snark! I have said it thrice: What I tell you three times is true." -- The Hunting of the Snark: an Agony in Eight Fits by Lewis Carroll (If you never have read it, or haven't read it in ages, it can be found in many locations on line. http://oldpoetry.com/volume/164 has illustrations by Mervyn Peake another site is http://www.snark.de/carroll/snark/) -- Robert I. Eachus �In an ally, considerations of house, clan, planet, race are insignificant beside two prime questions, which are: 1. Can he shoot? 2. Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and Steve Miller. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Ada.Streams.Stream_IO.File_Type 2003-07-15 20:13 Ada.Streams.Stream_IO.File_Type tmoran 2003-07-17 15:10 ` Ada.Streams.Stream_IO.File_Type Craig Carey 2003-07-17 16:01 ` Ada.Streams.Stream_IO.File_Type Nick Roberts @ 2003-07-18 7:46 ` Dmitry A. Kazakov 2 siblings, 0 replies; 11+ messages in thread From: Dmitry A. Kazakov @ 2003-07-18 7:46 UTC (permalink / raw) On Tue, 15 Jul 2003 20:13:37 GMT, tmoran@acm.org wrote: >Why is this not a descendant of Ada.Finalization.Limited_Controlled? Probably, because one wished to keep Streams free from tagged types. (specifications mention only 'Class, but no tagged types). However, it is brilliant example where interfaces inheritance and multiple inheritance could be useful: to override a decision made by a designer, you cannot influence. (:-)) --- Regards, Dmitry Kazakov www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-07-21 9:47 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-07-15 20:13 Ada.Streams.Stream_IO.File_Type tmoran 2003-07-17 15:10 ` Ada.Streams.Stream_IO.File_Type Craig Carey 2003-07-17 16:42 ` Ada.Streams.Stream_IO.File_Type Nick Roberts 2003-07-18 17:34 ` Ada.Streams.Stream_IO.File_Type Matthew Heaney 2003-07-18 18:25 ` Ada.Streams.Stream_IO.File_Type David C. Hoos 2003-07-17 16:01 ` Ada.Streams.Stream_IO.File_Type Nick Roberts 2003-07-20 11:27 ` Ada.Streams.Stream_IO.File_Type Mário Amado Alves 2003-07-20 14:25 ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus 2003-07-21 4:03 ` Ada.Streams.Stream_IO.File_Type Nick Roberts 2003-07-21 9:47 ` Ada.Streams.Stream_IO.File_Type Robert I. Eachus 2003-07-18 7:46 ` Ada.Streams.Stream_IO.File_Type Dmitry A. Kazakov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox