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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b3f788f59498d3af X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news2.arglkargh.de!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Exceptions and out procedure arguments (using GNAT GPL) Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <79c673pq5htg508nkoi935n3udqg5ps7r8@4ax.com> <1182181497.595409.300500@a26g2000pre.googlegroups.com> <1182238493.512406.168820@o61g2000hsh.googlegroups.com> <1182266486.650797.262430@a26g2000pre.googlegroups.com> Date: Tue, 19 Jun 2007 22:07:59 +0200 Message-ID: NNTP-Posting-Date: 19 Jun 2007 22:07:46 CEST NNTP-Posting-Host: c506ae08.newsspool4.arcor-online.net X-Trace: DXC=\==1e_34A6ZmG86`U=_nC_4IUKN5=QDNcfSJ;bb[UIRnRBaCdeZ[ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:16244 Date: 2007-06-19T22:07:46+02:00 List-Id: On Tue, 19 Jun 2007 08:21:26 -0700, Adam Beneschan wrote: > My gut feeling is that, in > the abstract, a subprogram should either produce a result *or* > (perhaps) raise an exception, but not both; in general, if your > definition of a subprogram is that, under certain conditions, the > subprogram will raise an exception AND the caller can expect a certain > value to be returned (whether in an OUT parameter or an IN OUT or a > global or in something pointed to by an access parameter or whatever) > even though an exception is raised, the design is wrong. It's better > to use an OUT status code of some sort in that case. I don't think this is a good advice. In my view a right design assumes that whether an exception is propagated or not, the subprogram should not leave anything in an undefined state. That is independent on the way an in-out parameter is passed. If the parameter is by-reference, then the subprogram shall document all side effects on it, which cannot be rolled back. (Thee is a quite specific case of non-initialized out parameters, but I don't like the idea of using that pattern rather than result anyway.) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de