comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian_drummond@btconnect.com>
Subject: Re: Naming convention to identify functions with side effects
Date: Fri, 03 Oct 2008 12:51:33 +0100
Date: 2008-10-03T12:51:33+01:00	[thread overview]
Message-ID: <fd0ce4ptnhuoo78ecu4em6op8nv5hnj338@4ax.com> (raw)
In-Reply-To: 48e13f14$0$6610$9b4e6d93@newsspool3.arcor-online.net

On Mon, 29 Sep 2008 22:48:20 +0200, Georg Bauhaus
<see.reply.to@maps.futureapps.de> wrote:

>Dmitry A. Kazakov wrote:
>> On Mon, 29 Sep 2008 11:55:49 -0700 (PDT), Adam Beneschan wrote:
>
>>>    if Web_Page_Is_Loaded ("http://www.irvine.com") then...
>>>    if Load_Web_Page ("http://www.irvine.com") then...
>> 
>> I don't like either.
>
>Me neither.
>
>Some issues become more obvious in a concurrent setting
>perhaps,
>
>   Web_Page.Load ("http://www.irvine.com");
>
>   if Web_Page.Is_Loaded then...
>
>There needs to be a lock of some sort joining the two calls.
>Otherwise, the Web_Page object might have changed
>between the two calls, a logic error.

As someone relatively new to Ada, I have to ask, is there need for
anything more sophisticated than

   Web_Page.Load ("http://www.irvine.com", Loaded);
   if Loaded then...

which avoids side effects in functions, preserves the atomicity of the
operation and test, but allows the test result to be used later. 
(The web page may indeed change, but "Loaded" refers to the version
extant during the .Load call)

Its intent and operation are quite clear, and it's a common paradigm in
other languages.

Beyond being a little untidy, is there any reason for avoiding it? 

- Brian




  parent reply	other threads:[~2008-10-03 11:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-29 18:17 Naming convention to identify functions with side effects Hibou57 (Yannick Duchêne)
2008-09-29 18:45 ` Hibou57 (Yannick Duchêne)
2008-09-29 18:55 ` Adam Beneschan
2008-09-29 19:52   ` Dmitry A. Kazakov
2008-09-29 20:48     ` Georg Bauhaus
2008-09-29 21:10       ` Adam Beneschan
2008-09-30 15:17         ` Georg Bauhaus
2008-09-30 17:40           ` Ray Blaak
2008-10-02 12:33       ` Ole-Hjalmar Kristensen
2008-10-03  9:18         ` Georg Bauhaus
2008-10-06  7:24           ` Ole-Hjalmar Kristensen
2008-10-03 11:51       ` Brian Drummond [this message]
2008-10-03 12:28         ` Dmitry A. Kazakov
2008-10-04 12:30           ` Marco
2008-10-04 13:05             ` (see below)
2008-10-04 15:14               ` Gary Scott
2008-10-11 11:32               ` Marco
2008-10-11 14:57                 ` Dmitry A. Kazakov
2008-10-11 16:05                 ` (see below)
2008-10-11 17:49                   ` Georg Bauhaus
2008-10-11 18:42                     ` (see below)
2008-10-03 13:15         ` Jeffrey Creem
2008-09-29 20:57 ` Georg Bauhaus
2008-09-29 22:22 ` Dr. Adrian Wrigley
replies disabled

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