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,7d3cb5920e882220 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!d27g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Exceptions Date: Fri, 7 Dec 2007 16:38:44 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1197074324 27083 127.0.0.1 (8 Dec 2007 00:38:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 8 Dec 2007 00:38:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d27g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ 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) Xref: g2news1.google.com comp.lang.ada:18771 Date: 2007-12-07T16:38:44-08:00 List-Id: On Dec 7, 10:59 am, Simon Wright wrote: > Adam Beneschan writes: > > On Dec 6, 7:00 am, shaunpatter...@gmail.com wrote: > >> Is there any way to force programmers to catch exception that > >> your function throws? > > > Not in Ada. If you're looking for, say, a pragma that you can put > > on a subprogram declaration to tell the compiler to reject any code > > that calls the subprogram in a place not governed by an exception > > handler for a specified exception---that's an interesting idea, and > > maybe if there's enough interest it could be added to a future > > revision of Ada, probably Annex H. I don't see any problem with a > > particular compiler vendor implementing a pragma like that, though, > > although of course it would be non-portable; perhaps you could ask > > your vendor if they'd be willing to implement something like that. > > It would probably not be too difficult to implement. > > I think this would be a very bad idea. I don't want to be forced to > deal with the exception 'here' when it would be better handled by my > caller. I wouldn't want that either. But this seems like a "coding standard" sort of thing that organizations sometimes impose to force their less- experienced programmers to be more careful. I know I'd grumble if I had to adhere to a standard like that, but some organizations seem to think it's a good thing anyway. I can see how a pragma like this could be useful in that sort of context. Hopefully the OP is talking about writing a function for internal use by other programmers in the same organization, not one that would be part of a library to be released to the public or for use by customers. If it's either of the last two, then it's definitely a bad idea---it shouldn't be any of his business how other outside users deal with exceptions. Unless, of course, the exception isn't really an exceptional condition but rather a "normal result" returned in a different way, which I think is a really, really bad idea. -- Adam