comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Mneson announcement and help request
Date: Thu, 3 Jun 2004 22:21:45 -0500
Date: 2004-06-03T22:21:45-05:00	[thread overview]
Message-ID: <-NSdneXjh7wndyLdRVn-vw@megapath.net> (raw)
In-Reply-To: c9melj$fg6$1@sparta.btinternet.com

"Martin Dowie" <martin.dowie@btopenworld.com> wrote in message
news:c9melj$fg6$1@sparta.btinternet.com...
> "Randy Brukardt" <randy@rrsoftware.com> wrote in message
> news:xK-dnZHKcKOszSPdRVn-ug@megapath.net...
> > Well, yes, because End_of_File for Text_IO is very expensive (it has to
do
> > lookahead of as many as two characters, and doing so makes later Gets
> > expensive as well). But "End_of_File" (or indeed any function call)
misses
> > the point.
>
> My point was that EOF is relatively cheap compared to raising the
exception
> not that it is cheap per se. And if GNAT and ObjectAda (the 2 compilers I
> have any source for) are typical of most implementations then this is
certainly
> true. OA even includes lots of local instantiations of the sort that MAA
was
> finding very slow (assuming OA is also "slow" in this regard).

My point was that as long as you keep the exception handler and raising out
of the loop (which is certainly true for EOF), it can be quite efficient. In
the normal case (where you read many characters before reaching the end of
the file), it's almost always better to handle the exception. That's because
one exception raise/handling pair is a lot cheaper than 10,000 function
calls, especially one as expensive as EOF. (And EOF is more expensive than
exception handling on Janus/Ada if it has to read lookahead, because system
calls always are more expensive than code that doesn't require system calls,
like exception handling. And I'd expect that to be true on most compilers,
as that is more of a function of the OS, not really of the compiler).

Now, the code you originally described (which did the exception raise and
handing inside the loop) would be awful on any compiler. But replacing it
with an expensive function (essentially any that aren't inlined) is not
going to be much help.

                        Randy.








  reply	other threads:[~2004-06-04  3:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-01 15:56 Mneson announcement and help request Marius Amado Alves
2004-06-02  2:26 ` Jeff C,
2004-06-02  3:06   ` Marius Amado Alves
2004-06-02 11:19     ` Georg Bauhaus
2004-06-02 11:41       ` Marius Amado Alves
     [not found]         ` <c9l0vo$pq3$1@sparta.btinternet.com>
2004-06-02 17:47           ` Marius Amado Alves
2004-06-02 19:46             ` Martin Dowie
2004-06-02 22:10           ` Randy Brukardt
2004-06-03  5:58             ` Martin Dowie
2004-06-04  3:21               ` Randy Brukardt [this message]
2004-06-04  5:55                 ` Martin Dowie
2004-06-04  7:30                   ` Jean-Pierre Rosen
2004-06-04 14:11                     ` Larry Kilgallen
2004-06-03  4:12           ` Jeffrey Carter
2004-06-03  5:48             ` Martin Dowie
2004-06-03  9:02             ` Martin Krischik
2004-06-02 11:41       ` Georg Bauhaus
2004-06-02 13:14         ` Marius Amado Alves
2004-06-03  4:09         ` Jeffrey Carter
2004-06-03 11:24           ` Georg Bauhaus
2004-06-02  3:21   ` Marius Amado Alves
2004-06-22 20:49     ` Jacob Sparre Andersen
2004-06-23  9:36       ` Marius Amado Alves
replies disabled

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