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,699cc914522aa7c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Structured exception information Date: Mon, 15 Jan 2007 17:19:33 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1168885771.30643.20.camel@localhost> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1168899573 10462 192.74.137.71 (15 Jan 2007 22:19:33 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 15 Jan 2007 22:19:33 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:+VSygn9t1lpyyNqIIiHXulPb2RE= Xref: g2news2.google.com comp.lang.ada:8144 Date: 2007-01-15T17:19:33-05:00 List-Id: Georg Bauhaus writes: > I'm still wondering whether or not an Ada compiler could provide > a special kind of closure for this case? We do already get stack > traces. (I don't know compilers so this is just a guess...) > > package Handling is > > -- > -- info to be attached to an exception occurence > -- > > type State is tagged record > info: Integer; > end record; > > end Handling; > > > with Handling; use Handling; > procedure foo is > > x: Integer; > > function Env return State'class is > begin > return State'(info => x); > end Env; > > begin > if 1 > 1 then > raise Constraint_Error with Env'access; > end if; > end foo; I'm not sure exactly what you mean by the above. Is Handling supposed to be provided by the Ada implementation? Is Env'Access pointing to a function or the result of calling the function (allocated where?)? Anyway, I think the goal is (should be) that when you attach information to an exception, there's a contract. That is, when you declare the exception, you declare the type of that information, and the "raise" statement and the handler both obey that contract. In this view, it makes no sense to attach miscellaneous info to Constraint_Error. How is a "when Constraint_Error" supposed to know the type of that info? Another goal, of course, is to allow the handler to do fine-grained or coarse-grained handling, without having to make that decision when you declare the exception. See Posix Ada-binding "errno" fiasco. Numerous languages have accomplished all of the above in a simple and elegant manner. It's not that hard. - Bob