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,cbb87dd49168c396 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-31 10:04:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3DC170A2.5050307@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Get_Line References: <3DBF3659.30709@acm.org> <4dRv9.46453$wm6.7691@nwrddc01.gnilink.net> <3DC0204E.4050203@acm.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 31 Oct 2002 18:04:40 GMT NNTP-Posting-Host: 63.184.9.196 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1036087480 63.184.9.196 (Thu, 31 Oct 2002 10:04:40 PST) NNTP-Posting-Date: Thu, 31 Oct 2002 10:04:40 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:30265 Date: 2002-10-31T18:04:40+00:00 List-Id: Preben Randhol wrote: > Jeffrey Carter wrote: > >> if Last >= Buffer'Last then > > ^^ Hmm, can Last be > than Buffer'Last ? [from a call to Get_Line to > read Buffer] It shouldn't. It might if your memory gets hit by a cosmic ray. But I usually code like this because 1. It's defensive coding. If I assume Last <= Buffer'Last, the code may go haywire if Last is ever > Buffer'Last. This isn't a very good example, but if I'm calculating something that determines when to exit a large loop, and I KNOW it will always be <= Exit_Value, and I exit when it's = Exit_Value, and then 4 years later someone incorrectly modifies the code so it becomes > Exit_Value trying to get it to exit sooner, then you have an infinite loop. If I exit when it's >= Exit_Value, it's more likely to be correct. The value has grown faster than expected, but it's still time to exit the loop. 2. [Last < Buffer'Last => Get_Line has skipped a line terminator] => [not (Last < Buffer'Last) => it has not skipped one] => [Last >= Buffer'Last => it has not skipped one]. Since I want to call Skip_Line when Get_Line has not skipped a line terminator, I use the last condition. -- Jeff Carter "If you think you got a nasty taunting this time, you ain't heard nothing yet!" Monty Python and the Holy Grail