From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d89e2d213646aec8 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 03 Jun 2004 22:21:30 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: Mneson announcement and help request Date: Thu, 3 Jun 2004 22:21:45 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: <-NSdneXjh7wndyLdRVn-vw@megapath.net> NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-HejqzTKHAJ6BAuOi9pC9PEdQKShFHyYSuAridFxI2dKCKQ8s4s9fUupRVqo8L+OzjbEAgZuxuTun2xg!CxcAR71vbn2uO96ujmvGmgmbppgkGuSFAEGNNidp+AJqCmS537MmRkaEgLHGCMZvKp/D+c9Mnivz X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: g2news1.google.com comp.lang.ada:1083 Date: 2004-06-03T22:21:45-05:00 List-Id: "Martin Dowie" wrote in message news:c9melj$fg6$1@sparta.btinternet.com... > "Randy Brukardt" 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.