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-Thread: 103376,7728b533f7ab5fb6 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!a1g2000hsb.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Avoiding side effects Date: Tue, 30 Sep 2008 03:42:42 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6f03481d-1f60-4bd8-97a5-d98576875afa@a1g2000hsb.googlegroups.com> References: NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1222771363 3674 127.0.0.1 (30 Sep 2008 10:42:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 30 Sep 2008 10:42:43 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a1g2000hsb.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3) Gecko/20040924,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2157 Date: 2008-09-30T03:42:42-07:00 List-Id: Anders Wirzenius wrote: > I create two functions, Strip and Advance. > function Strip (Remove_This : in String) return String > -- Displays rows until row > Remove_This. > function Advance (Candidate : in String) return String > -- Advance in file until row > Candidate. > The main program is then merely a loop where I alternate between > advancing lines in the two files until the row in the file is > greater than the value to compare against: ... > The problem is how to deal with the situation when I reach the > end of the file. ... Both of your functions already have the side effect of moving the current position in the input files, so I don't see why you would want to avoid side effects. I think Jean-Pierre's answer is good; use the exceptions that Ada.Text_IO propagates to indicate the end of file. -- Ludovic Brenta.