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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no 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-18 01:09:03 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!news.belwue.de!news.tesion.net!newsfeed-zh.ip-plus.net!news.ip-plus.net!not-for-mail From: Thomas Wolf Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: Fri, 18 Jul 2003 10:05:26 +0200 Organization: --- Message-ID: References: <1ec946d1.0307150715.4ba69f85@posting.google.com> <3F149243.80304@attbi.com> <3F15930C.2070907@attbi.com> <198fhv0avvpqc39dq7paiqpf3lntca8v4g@4ax.com> Reply-To: t_wolf@angelfire.com NNTP-Posting-Host: pargate2.paranor.ch X-Trace: rex.ip-plus.net 1058515577 12223 195.65.4.190 (18 Jul 2003 08:06:17 GMT) X-Complaints-To: abuse@ip-plus.net NNTP-Posting-Date: Fri, 18 Jul 2003 08:06:17 +0000 (UTC) X-Newsreader: MicroPlanet Gravity v2.60 Xref: archiver1.google.com comp.lang.ada:40457 Date: 2003-07-18T10:05:26+02:00 List-Id: mailbox@dmitry-kazakov.de wrote: > On Thu, 17 Jul 2003 19:36:19 +0200, "Jean-Pierre Rosen" > wrote: > > >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. > > ARM states for Get_Line: > > "... Reading stops if the end of the string is met. Reading also stops > if the end of the line is met before meeting the end of the string; in > this case Skip_Line is (in effect) called with a spacing of 1. The > values of characters not assigned are not specified." > > What will happen if a line is exactly of 500 character length? From > the quote above I suppose that Get_Line will boldly go to the next > line. If so, then your program would merge all lines of 500 character > length into one adding the first shorter line, or raise an unexpected No. If the line has 499 characters, they'll be read, Last will be 499, and Skip_Line (1) will be called, so that the *next* Get_Line will read the next line. If there are 501 characters on the line, the first 500 will be read, Last will be 500, Skip_Line will not be called, and the next Get_Line will read 1 character, Last will be 1, and Skip_Line (1) will be called. If there are exactly 500 characters on the line, they'll be read, and Last will be 500. Skip_Line *will not* be called, because Get_Line stops due to having met the end of the string (it hasn't yet met the end of the line). The *next* Get_Line will read zero characters, Last will be zero, and Skip_Line (1) will be called. -- ----------------------------------------------------------------- Thomas Wolf e-mail: t_wolf@angelfire.com