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,35d52809fb2aac8f X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps83.POSTED!7564ea0f!not-for-mail Sender: blaak@METROID 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> <2ed64106-52ef-4909-a0f0-ebb277856e8d@26g2000hsk.googlegroups.com> <48e24307$0$6583$9b4e6d93@newsspool4.arcor-online.net> From: Ray Blaak Message-ID: Organization: The Transcend User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 30 Sep 2008 17:40:48 GMT NNTP-Posting-Host: 154.20.96.87 X-Trace: edtnps83 1222796448 154.20.96.87 (Tue, 30 Sep 2008 11:40:48 MDT) NNTP-Posting-Date: Tue, 30 Sep 2008 11:40:48 MDT Xref: g2news1.google.com comp.lang.ada:2167 Date: 2008-09-30T17:40:48+00:00 List-Id: Georg Bauhaus writes: > I need more predicates. Since these are called before Load_Web_Page > is called, Load_Web_Page is "pushed down" the conditional chain, > hiding it and also blurring the distinct sources of error: > > if URL_Name /= null and then > Valid_Protocol (URL_Name.all) and then > Host_Allowed (URL_Name.all) and then > No_Up_Directories (URL_Name.all) and then > Load_Web_Page (URL_Name.all) > then ... > [stuff to do if all test succeed and the page was finally loaded] > else ... > [something has failed, maybe loading has failed, do other stuff] > end if; [...] > Finally, the programmer wanting to reduce verbosity by > making Load_Web_Page a Boolean function now causes > verbosity by chaining the many predicates. > This amount by far exceeds the intended reduction in verbosity > and renders the original intent (of saving words) mostly > fruitless. [...] > At this point I remember advice from The Little Schemer > to use little helper functions (that can be nested if > needed). Thus, > > if Is_Acceptable (URL_Name.all) then > Load_Web_Page (URL_Name.all, Data); > Construct (Data, Result); > else > raise Syntax_Error; > end if; Or, you could make Load_Web_Page only work if a page is valid: if Load_Web_Page (URL_Name.all, Data) then Construct (Data, Result); else raise Syntax_Error; end if; Or, my favourite, make Load_Web_Page be a procedure that wants only valid pages and have *it* throw any errors as needed: Load_Web_Page (URL_Name.all, Data); -- raises Syntax_Error if bad Construct (Data, Result); -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, rAYblaaK@STRIPCAPStelus.net The Rhythm has my soul.