comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Avoiding side effects
Date: Tue, 30 Sep 2008 03:42:42 -0700 (PDT)
Date: 2008-09-30T03:42:42-07:00	[thread overview]
Message-ID: <6f03481d-1f60-4bd8-97a5-d98576875afa@a1g2000hsb.googlegroups.com> (raw)
In-Reply-To: uljxa9o85.fsf@no.email.thanks.invalid

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.



  parent reply	other threads:[~2008-09-30 10:42 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30  5:50 Avoiding side effects Anders Wirzenius
2008-09-30  7:48 ` Jean-Pierre Rosen
2008-09-30  9:20   ` Anders Wirzenius
2008-09-30 11:36     ` Jean-Pierre Rosen
2008-09-30 12:43       ` Anders Wirzenius
2008-09-30 10:42 ` Ludovic Brenta [this message]
2008-09-30 11:12   ` Anders Wirzenius
2008-10-02 12:56 ` Ole-Hjalmar Kristensen
2008-10-06 12:09   ` Anders Wirzenius
2008-10-07 11:08     ` Ole-Hjalmar Kristensen
2008-10-07 14:24       ` (see below)
2008-10-07 14:47         ` Anders Wirzenius
2008-10-07 14:51           ` (see below)
2008-10-08  5:16             ` Anders Wirzenius
2008-10-08  7:35               ` Dmitry A. Kazakov
2008-10-08 15:32               ` (see below)
2008-10-13 12:27                 ` Anders Wirzenius
2008-10-13 13:21                   ` Marco
2008-10-13 18:55                     ` (see below)
2008-10-14  7:30                       ` Dmitry A. Kazakov
2008-10-14 11:44                         ` Colin Paul Gloster
2008-10-13 18:49                   ` (see below)
2008-10-13 21:22                     ` Adam Beneschan
2008-10-13 21:53                       ` (see below)
2008-10-14  6:17                         ` mockturtle
2008-10-14 14:58                           ` Adam Beneschan
2008-10-14  6:22                     ` Avoiding side effects and other dogma Anders Wirzenius
2008-10-14 13:48                       ` (see below)
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox