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 Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!nwrddc02.gnilink.net.POSTED!c9e1c1fe!not-for-mail From: Jeffrey Creem User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Naming convention to identify functions with side effects References: <5654ee5f-aa9f-4fff-87e0-45854b850f26@y38g2000hsy.googlegroups.com> <29ac62e1-78da-4048-ad95-8f88a29f7d31@z6g2000pre.googlegroups.com> <48e13f14$0$6610$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <0nghr5-dfc.ln1@newserver.thecreems.com> Date: Fri, 03 Oct 2008 13:15:01 GMT NNTP-Posting-Host: 71.181.45.230 X-Complaints-To: abuse@verizon.net X-Trace: nwrddc02.gnilink.net 1223039701 71.181.45.230 (Fri, 03 Oct 2008 09:15:01 EDT) NNTP-Posting-Date: Fri, 03 Oct 2008 09:15:01 EDT Xref: g2news1.google.com comp.lang.ada:2216 X-Original-Bytes: 3288 Date: 2008-10-03T13:15:01+00:00 List-Id: Brian Drummond wrote: > On Mon, 29 Sep 2008 22:48:20 +0200, Georg Bauhaus > 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 > Perfectly valid paradigm in an Ada program as well. The risk of a style like this is the traditional sloppy programming risk where one may just ignore Loaded and continue processing down the happy path. In some cases, this may mean that using an exception would have been a better choice. In other cases, this sort of a Loaded status would be fine. In most cases, getting too worked up about the micro-style issues between the exception and the status is a small issue compared to the architectural mess that people in general make of their code. Static analyzers and in many cases some compilers are pretty good about warning on cases where Loaded was written to but not read which can help manage the risk of sloppy programming.