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,386228a37afe967f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-17 14:56:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!news-out.visi.com!petbe.visi.com!ash.uu.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: 17 Jul 2003 17:47:52 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1ec946d1.0307150715.4ba69f85@posting.google.com> <3F149243.80304@attbi.com> <3F15930C.2070907@attbi.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1058478472 11949 199.172.62.241 (17 Jul 2003 21:47:52 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 17 Jul 2003 21:47:52 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:40443 Date: 2003-07-17T17:47:52-04:00 List-Id: "Jean-Pierre Rosen" writes: > This one reads a line with no length limit: > > function Get_Line return String is > Buffer : String (1..500); -- or whatever > Last : Natural; > begin > Get_Line (Buffer, Last); > if Last < Buffer'Last then > return Buffer (1..Last); > else > return Buffer & Get_Line; > end if; > end Get_Line; > > In most cases, there will be only one call, while having no upper limit. > The size of the buffer is just a matter of optimization. This is a nice trick, but I suggest you grow the buffer exponentially, in case lines are very long. Like, double it on each recursion level. Too bad this was not included in Text_IO itself. It would save beginners a lot of trouble. Sigh. - Bob