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,b3f788f59498d3af X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!a26g2000pre.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Exceptions and out procedure arguments (using GNAT GPL) Date: Tue, 19 Jun 2007 08:21:26 -0700 Organization: http://groups.google.com Message-ID: <1182266486.650797.262430@a26g2000pre.googlegroups.com> References: <79c673pq5htg508nkoi935n3udqg5ps7r8@4ax.com> <1182181497.595409.300500@a26g2000pre.googlegroups.com> <1182238493.512406.168820@o61g2000hsh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1182266487 474 127.0.0.1 (19 Jun 2007 15:21:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 19 Jun 2007 15:21:27 +0000 (UTC) In-Reply-To: <1182238493.512406.168820@o61g2000hsh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: a26g2000pre.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:16240 Date: 2007-06-19T08:21:26-07:00 List-Id: On Jun 19, 12:34 am, Maciej Sobczak wrote: > On 19 Cze, 07:23, Fionn Mac Cumhaill > wrote: > > > I eliminated the problem by modifying the offending procedure to not > > raise exceptions. It now returns a status code in an additional out > > argument. > > You might also introduce a temporary variable in the procedure to keep > the "candidate" result and copy it into the relevant out parameter > just before leaving the procedure (on the successful path). > This would be better than changing the interface and error handling > policy, which is very intrusive. But it might be the correct design anyway. 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. Sorry if I'm not explaining this well---I don't always know what the common terminology is for the things I'm thinking. Also, I'm not saying that this necessarily applies to Fionn's program. -- Adam