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!news4.google.com!proxad.net!feeder1-2.proxad.net!fdn.fr!feeder.erje.net!feeder2.news.saunalahti.fi!feeder1.news.saunalahti.fi!nntp.inet.fi!central1.inet.fi!inet.fi!read4.inet.fi.POSTED!53ab2750!not-for-mail Sender: AWI003@FIW9752 Newsgroups: comp.lang.ada Subject: Re: Avoiding side effects References: <6f03481d-1f60-4bd8-97a5-d98576875afa@a1g2000hsb.googlegroups.com> From: Anders Wirzenius Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 30 Sep 2008 11:12:35 GMT NNTP-Posting-Host: 194.251.142.2 X-Complaints-To: abuse@inet.fi X-Trace: read4.inet.fi 1222773155 194.251.142.2 (Tue, 30 Sep 2008 14:12:35 EEST) NNTP-Posting-Date: Tue, 30 Sep 2008 14:12:35 EEST Organization: Sonera Customer Xref: g2news1.google.com comp.lang.ada:2160 Date: 2008-09-30T11:12:35+00:00 List-Id: Ludovic Brenta writes: > 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. Yes, you are right. The design in itself contains at least one side effect. Thanks to both of you, Jean-Pierre and Ludovic. -- Anders