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,794c64d1f9164710 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-21 18:56:56 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: functions, packages & characters Date: Thu, 21 Feb 2002 20:57:55 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <20020221130715.12738.00000034@mb-bg.aol.com> <3C753C66.8020509@mail.com> X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:20244 Date: 2002-02-21T20:57:55-06:00 List-Id: Matthew Heaney wrote in message ... >"Randy Brukardt" wrote in message >news:u7b1g6cooeo49@corp.supernews.com... >> It is possible to write such a >> Get_Line out of the primitives in Text_IO, but the result would be >> unacceptably slow (because you would have to read a character at a >> time - you can't use Get_Line because you can't tell between the case of >> a line which exactly fills the buffer and a line which is too long and >> does not -- but in the former case, the line terminator is skipped). > >This statement is incorrect. Not exactly. This was true in Ada 83, but it was fixed circa 1985 (and added to the validation tests a couple of years later [AI83-00050]). There are a bunch of comments in our Text_IO implementation about this change. Still, I must be going senile: all I can imagine is that I "learned" about Get_Line when this was true (at least in the compiler I used), and haven't forgotten the "rule" even though it hasn't been true in a long time. >You can search comp.lang.ada at google.com for several posts I've written on >this very subject (search for "get_line"). Not interested; I've been using Get_Line since before you were born. :-) (OK, not really...) > loop > Get_Line (Line, Last); > Append (Buffer, Line (Line'First .. Last)); > exit when Last < Line'Last; > end loop; This is, of course, the inefficiency that I was commenting on. This would be slow, and would cause an awful lot of memory allocation and deallocation, with the possible exception of the first iteration. It would only be a good idea if the size of Line was larger than almost all expected lines. (Personally, I never use Unbounded strings, mainly because it took me years to figure out how to use regular Ada strings effectively, and Unbounded strings don't buy anything if you are used to doing that.) Randy Brukardt