comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthewjheaney@earthlink.net>
Subject: Re: Terminating a task
Date: Wed, 16 Jul 2003 05:26:41 GMT
Date: 2003-07-16T05:26:41+00:00	[thread overview]
Message-ID: <lm5Ra.103383$Io.8889946@newsread2.prod.itd.earthlink.net> (raw)
In-Reply-To: 5ra8hvkkabsvevc2r0abu4mp71dfochelr@4ax.com


"Craig Carey" <research@ijs.co.nz> wrote in message
news:5ra8hvkkabsvevc2r0abu4mp71dfochelr@4ax.com...
>
> Ada 95 can't read data accurately from the console: (a) Text_IO has an
> undefined behaviour on what bounds lines.

No, Text_IO doesn't define what control characters terminate a line, but
that's the whole point, to abstract away the representation of a line of
text.  And of course, the behavior of Text_IO wrt consumption of a line of
text is defined.

So I still don't know what you're talking about.  The programs I posted all
work fine using Text_IO.


>The Stream_IO package does not
> let the standard input be specified. GNAT extensions were not used (i.e.
> fread() in Interfaces.C_Streams).

This is irrelevent.

The point of the shootout was to use the standard idioms for the language.
So in Ada, if you want to consume a line of text from standard input, that
means using Text_IO.Get_Line.

To test whether you've consumed the entire line, do this:

declare
   Line : String (1 .. N);
  Last : Natural;
begin
   Get_Line (Line, Last);

   if Last < Line'Last then --we've consumed the entire line
...
end;

See my CLA post with the subject "Get_Line Mystery" (it's archived at
adapower.com), which explains how Get_Line works.


> My code is better:  http://dada.perl.it/shootout/gnat_allsrc.html

Your code is a completely incomprehensible mess.


> A program called "word counter" need not receive data containing text.

I don't care to speculate what the behavior is of a program that counts
lines of text, if the input isn't text.

Certainly, the input.txt file he used to test the wc programs is text, so it
is pointless to debate what should happen if the input file is not text.


> Ada.Text_IO was not portable over to ObjectAda 7.2.2: End_Error on a
> missing NL at the end of the file.

The program I wrote should not raise End_Error.  If it does, then the
compiler is broken, and you should take the matter up with Aonix.


> Using Ada.Text_IO's Read_Line is not
> safe in presumably all samples programs if GNAT might not be used.

I am not familiar with any Text_IO operation called Read_Line.

-Matt





  parent reply	other threads:[~2003-07-16  5:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-12 14:03 Terminating a task kat-Zygfryd
2003-07-12 14:37 ` kat-Zygfryd
2003-07-14  9:34   ` Craig Carey
2003-07-14 23:45     ` Matthew Heaney
2003-07-15 17:49       ` Craig Carey
2003-07-15 18:30         ` David C. Hoos
2003-07-16  5:26         ` Matthew Heaney [this message]
2003-07-15 22:37       ` Robert I. Eachus
2003-07-16  5:00         ` Matthew Heaney
2003-07-16 18:19           ` Robert I. Eachus
replies disabled

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